brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.0 KiB · d9a65ee Raw
45 lines · cpp
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-exception6//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++1718// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS19 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