xref: /llvm-project/libcxx/test/std/utilities/memory/default.allocator/allocator.ctor.pass.cpp (revision eb12d9b5cb6d15ce151a63ad32b4e0e5823ddb87)
1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <memory>
10 //
11 // template <class T>
12 // class allocator
13 // {
14 // public: // All of these are constexpr after C++17
15 //  allocator() noexcept;
16 //  allocator(const allocator&) noexcept;
17 //  template<class U> allocator(const allocator<U>&) noexcept;
18 // ...
19 // };
20 
21 #include <memory>
22 #include <cstddef>
23 
24 #include "test_macros.h"
25 
26 template<class T>
test()27 TEST_CONSTEXPR_CXX20 bool test() {
28   typedef std::allocator<T> A1;
29   typedef std::allocator<long> A2;
30 
31   A1 a1;
32   A1 a1_copy = a1; (void)a1_copy;
33   A2 a2 = a1; (void)a2;
34 
35   return true;
36 }
37 
main(int,char **)38 int main(int, char**) {
39   test<char>();
40   test<int>();
41   test<void>();
42 
43 #if TEST_STD_VER > 17
44   static_assert(test<char>());
45   static_assert(test<int>());
46   static_assert(test<void>());
47 #endif
48   return 0;
49 }
50