1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // UNSUPPORTED: c++98, c++03, c++11
11 
12 // <experimental/any>
13 
14 // Check that the size and alignment of any are what we expect.
15 
16 #include <experimental/any>
17 #include "any_helpers.h"
18 
19 class SmallThrowsDtor
20 {
21 public:
SmallThrowsDtor()22     SmallThrowsDtor() {}
SmallThrowsDtor(SmallThrowsDtor const &)23     SmallThrowsDtor(SmallThrowsDtor const &) noexcept {}
SmallThrowsDtor(SmallThrowsDtor &&)24     SmallThrowsDtor(SmallThrowsDtor &&) noexcept {}
~SmallThrowsDtor()25     ~SmallThrowsDtor() noexcept(false) {}
26 };
27 
main()28 int main()
29 {
30     using std::experimental::any;
31     using std::experimental::__any_imp::_IsSmallObject;
32     static_assert(_IsSmallObject<small>::value, "");
33     static_assert(_IsSmallObject<void*>::value, "");
34     static_assert(!_IsSmallObject<SmallThrowsDtor>::value, "");
35     static_assert(!_IsSmallObject<large>::value, "");
36     // long double is over aligned.
37     static_assert(sizeof(long double) <= sizeof(void*) * 3, "");
38     static_assert(alignof(long double) > alignof(void*), "");
39     static_assert(!_IsSmallObject<long double>::value, "");
40 }
41