1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <memory>
10
11// allocator:
12// pointer address(reference x) const;
13// const_pointer address(const_reference x) const;
14
15// Removed in C++20, deprecated in C++17.
16
17// REQUIRES: c++03 || c++11 || c++14 || c++17
18// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS
19
20#include <memory>
21#include <cassert>
22
23#include "test_macros.h"
24
25template <class T>
26void test_address() {
27 T* tp = new T();
28 const T* ctp = tp;
29 const std::allocator<T> a;
30 assert(a.address(*tp) == tp);
31 assert(a.address(*ctp) == tp);
32 delete tp;
33}
34
35struct A {
36 void operator&() const {}
37};
38
39int main(int, char**) {
40 test_address<int>();
41 test_address<A>();
42
43 return 0;
44}
45

source code of libcxx/test/libcxx/depr/depr.default.allocator/allocator.members/address.cxx20.pass.cpp