address.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// allocator:
13// pointer address(reference x) const;
14// const_pointer address(const_reference x) const;
15
16#include <memory>
17#include <cassert>
18
19template <class T>
20void test_address()
21{
22    T* tp = new T();
23    const T* ctp = tp;
24    const std::allocator<T> a;
25    assert(a.address(*tp) == tp);
26    assert(a.address(*ctp) == tp);
27    delete tp;
28}
29
30struct A
31{
32    void operator&() const {}
33};
34
35int main()
36{
37    test_address<int>();
38    test_address<A>();
39}
40