[AMDGPU] Mark AGPR tuple implicit in the first instr of AGPR spills. (#115285)
[llvm-project.git] / libcxx / test / std / utilities / memory / pointer.traits / ptr.pointer_to.pass.cpp
blob104d507330c0b765e45a3ba73e4841566e092d4b
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 T>
12 // struct pointer_traits<T*>
13 // {
14 // static pointer pointer_to(<details>) noexcept; // constexpr in C++20
15 // ...
16 // };
18 #include <memory>
19 #include <cassert>
20 #include <type_traits>
22 #include "test_macros.h"
24 TEST_CONSTEXPR_CXX20 bool test()
26 // pointer_traits<T*>
28 int i = 0;
29 static_assert(std::is_same<decltype(std::pointer_traits<int*>::pointer_to(i)), int*>::value, "");
30 ASSERT_NOEXCEPT(std::pointer_traits<int*>::pointer_to(i));
31 assert(std::pointer_traits<int*>::pointer_to(i) == &i);
33 // pointer_traits<const T*>
35 int const i = 0;
36 static_assert(std::is_same<decltype(std::pointer_traits<const int*>::pointer_to(i)), const int*>::value, "");
37 ASSERT_NOEXCEPT(std::pointer_traits<const int*>::pointer_to(i));
38 assert(std::pointer_traits<const int*>::pointer_to(i) == &i);
40 // pointer_traits<const T*> with a non-const argument
42 int i = 0;
43 static_assert(std::is_same<decltype(std::pointer_traits<const int*>::pointer_to(i)), const int*>::value, "");
44 ASSERT_NOEXCEPT(std::pointer_traits<const int*>::pointer_to(i));
45 assert(std::pointer_traits<const int*>::pointer_to(i) == &i);
47 return true;
50 int main(int, char**)
52 test();
53 #if TEST_STD_VER > 17
54 static_assert(test());
55 #endif
58 // Check that pointer_traits<void*> is still well-formed, even though it has no pointer_to.
59 static_assert(std::is_same<std::pointer_traits<void*>::element_type, void>::value, "");
60 static_assert(std::is_same<std::pointer_traits<const void*>::element_type, const void>::value, "");
61 static_assert(std::is_same<std::pointer_traits<volatile void*>::element_type, volatile void>::value, "");
64 return 0;