Skip to content
This repository was archived by the owner on Jan 29, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions proxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,10 @@ consteval auto merge_constraints(proxiable_ptr_constraints a,
a = make_destructible(a, b.destructibility);
return a;
}
consteval std::size_t max_align_of(std::size_t value) {
value &= ~value + 1u;
return value < alignof(std::max_align_t) ? value : alignof(std::max_align_t);
}

template <bool IS_DIRECT, class D, class... Os>
struct conv_impl {
Expand Down Expand Up @@ -1184,8 +1188,8 @@ struct basic_facade_builder {
details::merge_conv_tuple_t<Cs, typename F::convention_types>,
details::merge_tuple_t<Rs, typename F::reflection_types>,
details::merge_constraints(C, F::constraints)>;
template <std::size_t PtrSize, std::size_t PtrAlign =
PtrSize < alignof(std::max_align_t) ? PtrSize : alignof(std::max_align_t)>
template <std::size_t PtrSize,
std::size_t PtrAlign = details::max_align_of(PtrSize)>
requires(std::has_single_bit(PtrAlign) && PtrSize % PtrAlign == 0u)
using restrict_layout = basic_facade_builder<
Cs, Rs, details::make_restricted_layout(C, PtrSize, PtrAlign)>;
Expand Down
7 changes: 7 additions & 0 deletions tests/proxy_traits_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,4 +330,11 @@ struct BigFacade : pro::facade_builder
::build {};
static_assert(sizeof(pro::proxy<BigFacade>) == 3 * sizeof(void*)); // Accessors should not add paddings

struct FacadeWithSizeOfNonPowerOfTwo : pro::facade_builder
::restrict_layout<6u>
::build {};
static_assert(pro::facade<FacadeWithSizeOfNonPowerOfTwo>);
static_assert(FacadeWithSizeOfNonPowerOfTwo::constraints.max_size == 6u);
static_assert(FacadeWithSizeOfNonPowerOfTwo::constraints.max_align == 2u);

} // namespace