aboutsummaryrefslogtreecommitdiff
path: root/libstdc++-v3/testsuite/20_util/any/layout.cc
blob: 5a7f4a8a280f3d07c1bd88484246d270cf8f8c45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// { dg-options "-Wno-deprecated-declarations" }
// { dg-do compile { target c++17 } }

// Verify that r15-3419 did not change the layout of std::any

#include <any>

namespace test {
  class any {
    union Storage {
      constexpr Storage() : ptr(nullptr) { }
      void* ptr;
      std::aligned_storage<sizeof(ptr), alignof(void*)>::type buffer;
    };

    void (*manager)(int, const any*, void*);
    Storage storage;
  };
}

static_assert( sizeof(std::any) == sizeof(test::any) );
static_assert( alignof(std::any) == alignof(test::any) );