1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 // 10 // UNSUPPORTED: libcpp-has-no-threads 11 12 // <atomic> 13 14 // template <class T> 15 // void 16 // atomic_store_explicit(volatile atomic<T>* obj, T desr, memory_order m); 17 // 18 // template <class T> 19 // void 20 // atomic_store_explicit(atomic<T>* obj, T desr, memory_order m); 21 22 #include <atomic> 23 #include <type_traits> 24 #include <cassert> 25 26 #include "atomic_helpers.h" 27 28 template <class T> 29 struct TestFn { 30 void operator()() const { 31 typedef std::atomic<T> A; 32 A t; 33 std::atomic_store_explicit(&t, T(1), std::memory_order_seq_cst); 34 assert(t == T(1)); 35 volatile A vt; 36 std::atomic_store_explicit(&vt, T(2), std::memory_order_seq_cst); 37 assert(vt == T(2)); 38 } 39 }; 40 41 42 int main() 43 { 44 TestEachAtomicType<TestFn>()(); 45 } 46