[LoongArch] Supports FP_TO_SINT operation for fp16 (#118303)
[llvm-project.git] / libcxx / test / std / utilities / memory / allocator.traits / allocator.traits.members / allocate.pass.cpp
blobab354f42a1d82485153a15401b3e6859ea66430c
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 //===----------------------------------------------------------------------===//
9 // <memory>
11 // template <class Alloc>
12 // struct allocator_traits
13 // {
14 // static constexpr pointer allocate(allocator_type& a, size_type n);
15 // ...
16 // };
18 #include <memory>
19 #include <cstdint>
20 #include <cassert>
22 #include "test_macros.h"
23 #include "incomplete_type_helper.h"
25 template <class T>
26 struct A
28 typedef T value_type;
30 TEST_CONSTEXPR_CXX20 A() {}
32 TEST_CONSTEXPR_CXX20 value_type* allocate(std::size_t n)
34 assert(n == 10);
35 return &storage;
38 value_type storage;
41 TEST_CONSTEXPR_CXX20 bool test()
44 A<int> a;
45 assert(std::allocator_traits<A<int> >::allocate(a, 10) == &a.storage);
48 typedef A<IncompleteHolder*> Alloc;
49 Alloc a;
50 assert(std::allocator_traits<Alloc>::allocate(a, 10) == &a.storage);
53 return true;
56 int main(int, char**)
58 test();
59 #if TEST_STD_VER > 17
60 static_assert(test());
61 #endif
62 return 0;