diff options
| author | Eric Fiselier <eric@efcs.ca> | 2016-03-17 03:30:56 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2016-03-17 03:30:56 +0000 |
| commit | a58d430cace221fa3959962b8d374d968891aba3 (patch) | |
| tree | 44695d3428667aee069455ba85bc52006f2e698d /libcxx/test | |
| parent | a7c4760c8efa0e7ad3564bb1a0966bf8940463cf (diff) | |
| download | bcm5719-llvm-a58d430cace221fa3959962b8d374d968891aba3.tar.gz bcm5719-llvm-a58d430cace221fa3959962b8d374d968891aba3.zip | |
Make std::addressof constexpr in C++17 (Clang only).
llvm-svn: 263688
Diffstat (limited to 'libcxx/test')
| -rw-r--r-- | libcxx/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp b/libcxx/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp new file mode 100644 index 00000000000..a371f8eda1a --- /dev/null +++ b/libcxx/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp @@ -0,0 +1,42 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03, c++11, c++14 +// XFAIL: gcc + +// <memory> + +// template <ObjectType T> constexpr T* addressof(T& r); + +#include <memory> +#include <cassert> + +struct Pointer { + constexpr Pointer(void* v) : value(v) {} + void* value; +}; + +struct A +{ + constexpr A() : n(42) {} + void operator&() const { } + int n; +}; + +constexpr int i = 0; +constexpr double d = 0.0; +constexpr A a{}; + +int main() +{ + static_assert(std::addressof(i) == &i, ""); + static_assert(std::addressof(d) == &d, ""); + constexpr const A* ap = std::addressof(a); + static_assert(&ap->n == &a.n, ""); +} |

