1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// UNSUPPORTED: c++98, c++03, c++11, c++14
11// XFAIL: gcc-4, gcc-5, gcc-6
12
13// <memory>
14
15// template <ObjectType T> constexpr T* addressof(T& r);
16
17#include <memory>
18#include <cassert>
19
20struct Pointer {
21  constexpr Pointer(void* v) : value(v) {}
22  void* value;
23};
24
25struct A
26{
27    constexpr A() : n(42) {}
28    void operator&() const { }
29    int n;
30};
31
32constexpr int i = 0;
33constexpr double d = 0.0;
34constexpr A a{};
35
36int main()
37{
38    static_assert(std::addressof(i) == &i, "");
39    static_assert(std::addressof(d) == &d, "");
40    constexpr const A* ap = std::addressof(a);
41    static_assert(&ap->n == &a.n, "");
42}
43