brintos

brintos / llvm-project-archived public Read only

0
0
Text · 837 B · e0db6a9 Raw
38 lines · cpp
1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7 8// REQUIRES: std-at-least-c++269 10// constexpr T* address() const noexcept;11 12#include <atomic>13#include <cassert>14#include <concepts>15#include <memory>16 17#include "atomic_helpers.h"18#include "test_macros.h"19 20template <typename T>21struct TestAddress {22  void operator()() const {23    T x(T(1));24    const std::atomic_ref<T> a(x);25 26    std::same_as<T*> decltype(auto) p = a.address();27    assert(std::addressof(x) == p);28 29    static_assert(noexcept((a.address())));30  }31};32 33int main(int, char**) {34  TestEachAtomicType<TestAddress>()();35 36  return 0;37}38