38 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// UNSUPPORTED: c++03, c++11, c++14, c++1710 11// <atomic>12 13// explicit atomic_ref(T&);14 15#include <atomic>16#include <type_traits>17 18#include "atomic_helpers.h"19#include "test_macros.h"20 21template <typename T>22struct TestCtor {23 void operator()() const {24 // check that the constructor is explicit25 static_assert(!std::is_convertible_v<T, std::atomic_ref<T>>);26 static_assert(std::is_constructible_v<std::atomic_ref<T>, T&>);27 28 T x(T(0));29 std::atomic_ref<T> a(x);30 (void)a;31 }32};33 34int main(int, char**) {35 TestEachAtomicType<TestCtor>()();36 return 0;37}38