addressof.pass.cpp revision bc8d3f97eb5c958007f2713238472e0c1c8fe02c
1//===----------------------------------------------------------------------===//
2//
3// ��������������������The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <memory>
11
12// template <ObjectType T> T* addressof(T& r);
13
14#include <memory>
15#include <cassert>
16
17struct A
18{
19    void operator&() const {}
20};
21
22int main()
23{
24    int i;
25    double d;
26    assert(std::addressof(i) == &i);
27    assert(std::addressof(d) == &d);
28    A* tp = new A;
29    const A* ctp = tp;
30    assert(std::addressof(*tp) == tp);
31    assert(std::addressof(*ctp) == tp);
32    delete tp;
33}
34