Home | History | Annotate | Download | only in atomics.types.operations.req
      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 //  ... assertion fails line 35
     12 
     13 // <atomic>
     14 
     15 // template <class T>
     16 //     T
     17 //     atomic_load(const volatile atomic<T>* obj);
     18 //
     19 // template <class T>
     20 //     T
     21 //     atomic_load(const atomic<T>* obj);
     22 
     23 #include <atomic>
     24 #include <type_traits>
     25 #include <cassert>
     26 
     27 #include "atomic_helpers.h"
     28 
     29 template <class T>
     30 struct TestFn {
     31   void operator()() const {
     32     typedef std::atomic<T> A;
     33     A t;
     34     std::atomic_init(&t, T(1));
     35     assert(std::atomic_load(&t) == T(1));
     36     volatile A vt;
     37     std::atomic_init(&vt, T(2));
     38     assert(std::atomic_load(&vt) == T(2));
     39   }
     40 };
     41 
     42 int main()
     43 {
     44     TestEachAtomicType<TestFn>()();
     45 }
     46