//===----------------------------------------------------------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// // // template // struct pointer_traits // { // static pointer pointer_to(
) noexcept; // constexpr in C++20 // ... // }; #include #include #include #include "test_macros.h" TEST_CONSTEXPR_CXX20 bool test() { // pointer_traits { int i = 0; static_assert(std::is_same::pointer_to(i)), int*>::value, ""); ASSERT_NOEXCEPT(std::pointer_traits::pointer_to(i)); assert(std::pointer_traits::pointer_to(i) == &i); } // pointer_traits { int const i = 0; static_assert(std::is_same::pointer_to(i)), const int*>::value, ""); ASSERT_NOEXCEPT(std::pointer_traits::pointer_to(i)); assert(std::pointer_traits::pointer_to(i) == &i); } // pointer_traits with a non-const argument { int i = 0; static_assert(std::is_same::pointer_to(i)), const int*>::value, ""); ASSERT_NOEXCEPT(std::pointer_traits::pointer_to(i)); assert(std::pointer_traits::pointer_to(i) == &i); } return true; } int main(int, char**) { test(); #if TEST_STD_VER > 17 static_assert(test()); #endif { // Check that pointer_traits is still well-formed, even though it has no pointer_to. static_assert(std::is_same::element_type, void>::value, ""); static_assert(std::is_same::element_type, const void>::value, ""); static_assert(std::is_same::element_type, volatile void>::value, ""); } return 0; }