Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Quuxplusone committed Aug 23, 2024
1 parent bb64856 commit 7e18dd8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
5 changes: 3 additions & 2 deletions include/sg14/aa_inplace_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,10 @@ struct SG14_INPLACE_VECTOR_TRIVIALLY_RELOCATABLE_IF((sg14::aaipv::be_trivially_r
// There is a feature-test macro for "conditionally trivial SMFs," namely
// (__cpp_concepts >= 202002L); but in fact neither GCC 11.4 nor AppleClang 15
// set that macro, despite supporting the feature (at least well enough to
// compile this code). So just check (__cplusplus >= 202002L) instead.
// compile this code). We could check (__cplusplus >= 202002L) instead,
// except that MSVC doesn't always set *that*! So check nothing, at least for now.
//
static_assert(__cplusplus >= 202002L, "Allocator-aware inplace_vector requires that the compiler support conditionally trivial SMFs");
static_assert(true, "Allocator-aware inplace_vector requires that the compiler support conditionally trivial SMFs");

static constexpr bool CopyCtorIsDefaultable =
((std::is_trivially_copy_constructible_v<T> &&
Expand Down
13 changes: 12 additions & 1 deletion test/aa_inplace_vector_smallsize_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,22 @@ namespace smallsize {

TEST(IPV_TEST_NAME, SizeAndAlignment)
{
#ifdef _MSC_VER
// Our `ipv_alloc_holder` has a single [[no_unique_address]] member.
// Even using [[msvc::no_unique_address]], MSVC fails to treat
// `ipv_alloc_holder` as an empty base for the purposes of optimization,
// which means it occupies an extra byte compared to the Itanium ABI.
//
static constexpr bool msvc = true;
#else
static constexpr bool msvc = false;
#endif

static_assert(sizeof(sg14::inplace_vector<char, 22>) == 32);
static_assert(alignof(sg14::inplace_vector<char, 22>) == 8);
static_assert(sizeof(sg14::pmr::inplace_vector<char, 22>) == 40);
static_assert(alignof(sg14::pmr::inplace_vector<char, 22>) == 8);
static_assert(sizeof(smallsize::inplace_vector<char, 22>) == 23);
static_assert(sizeof(smallsize::inplace_vector<char, 22>) == (msvc ? 24 : 23));
static_assert(alignof(smallsize::inplace_vector<char, 22>) == 1);

static_assert(sizeof(smallsize::inplace_vector<char, 2>) == 3);
Expand Down

0 comments on commit 7e18dd8

Please sign in to comment.