[LoongArch] Supports FP_TO_SINT operation for fp16 (#118303)
[llvm-project.git] / libcxx / test / std / utilities / memory / allocator.traits / allocator.traits.members / deallocate.pass.cpp
blob2f153eedc6fcd01061d61a3ac827299a5178f4ba
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 void deallocate(allocator_type& a, pointer p, size_type n);
15 // ...
16 // };
18 #include <memory>
19 #include <cassert>
20 #include <cstddef>
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(int& called) : called_(called) {}
32 TEST_CONSTEXPR_CXX20 void deallocate(value_type* p, std::size_t n)
34 assert(p == &storage);
35 assert(n == 10);
36 ++called_;
39 int& called_;
41 value_type storage;
44 TEST_CONSTEXPR_CXX20 bool test()
47 int called = 0;
48 A<int> a(called);
49 std::allocator_traits<A<int> >::deallocate(a, &a.storage, 10);
50 assert(called == 1);
53 int called = 0;
54 typedef A<IncompleteHolder*> Alloc;
55 Alloc a(called);
56 std::allocator_traits<Alloc>::deallocate(a, &a.storage, 10);
57 assert(called == 1);
60 return true;
63 int main(int, char**)
65 test();
66 #if TEST_STD_VER > 17
67 static_assert(test());
68 #endif
69 return 0;