mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-24 03:32:35 +08:00

Summary: P1006 adds support for constexpr in the specialization of pointer_traits for raw pointers. This is necessary in order to use pointer_traits in the upcoming constexpr containers. We expect P1006 to be voted into the working draft for C++20 at the San Diego meeting. Reviewers: mclow.lists, EricWF Subscribers: christof, dexonsmith, libcxx-commits Differential Revision: https://reviews.llvm.org/D53867 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@346764 91177308-0d34-0410-b5e6-96231b3b80d8
45 lines
1.0 KiB
C++
45 lines
1.0 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
// Source Licenses. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// <memory>
|
|
|
|
// template <class T>
|
|
// struct pointer_traits<T*>
|
|
// {
|
|
// static pointer pointer_to(<details>); // constexpr in C++20
|
|
// ...
|
|
// };
|
|
|
|
#include <memory>
|
|
#include <cassert>
|
|
#include "test_macros.h"
|
|
|
|
#if TEST_STD_VER > 17
|
|
constexpr
|
|
#endif
|
|
bool check() {
|
|
{
|
|
int i = 0;
|
|
static_assert((std::is_same<int *, decltype(std::pointer_traits<int*>::pointer_to(i))>::value), "");
|
|
int* a = std::pointer_traits<int*>::pointer_to(i);
|
|
assert(a == &i);
|
|
}
|
|
{
|
|
(std::pointer_traits<void*>::element_type)0;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
int main() {
|
|
check();
|
|
#if TEST_STD_VER > 17
|
|
static_assert(check(), "");
|
|
#endif
|
|
}
|