xref: /llvm-project/libcxx/test/std/atomics/atomics.ref/deduction.pass.cpp (revision 42ba740afffa16f991be6aa36626bd872d41ebc0)
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 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 
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 
21 template <typename T>
22 struct TestDeduction {
operator ()TestDeduction23   void operator()() const {
24     T x(T(0));
25     std::atomic_ref a(x);
26     ASSERT_SAME_TYPE(decltype(a), std::atomic_ref<T>);
27   }
28 };
29 
main(int,char **)30 int main(int, char**) {
31   TestEachAtomicType<TestDeduction>()();
32   return 0;
33 }
34