memory_order __m) noexcept
{ return __a->test_and_set(__m); }
+#if __cpp_lib_atomic_flag_test
+ inline bool
+ atomic_flag_test(const atomic_flag* __a) noexcept
+ { return __a->test(); }
+
+ inline bool
+ atomic_flag_test(const volatile atomic_flag* __a) noexcept
+ { return __a->test(); }
+
+ inline bool
+ atomic_flag_test_explicit(const atomic_flag* __a,
+ memory_order __m) noexcept
+ { return __a->test(__m); }
+
+ inline bool
+ atomic_flag_test_explicit(const volatile atomic_flag* __a,
+ memory_order __m) noexcept
+ { return __a->test(__m); }
+#endif
+
inline void
atomic_flag_clear_explicit(atomic_flag* __a, memory_order __m) noexcept
{ __a->clear(__m); }
#include <atomic>
#include <testsuite_hooks.h>
-int main()
+void
+test01()
{
using namespace std;
VERIFY( ! af.test(memory_order_acquire) );
VERIFY( ! caf.test(memory_order_acquire) );
}
+
+void
+test02()
+{
+ using namespace std;
+
+ atomic_flag af{true};
+ const atomic_flag& caf = af;
+
+ VERIFY( atomic_flag_test_explicit(&af, memory_order_acquire) );
+ VERIFY( atomic_flag_test_explicit(&caf, memory_order_acquire) );
+ af.clear(memory_order_release);
+ VERIFY( ! atomic_flag_test_explicit(&af, memory_order_acquire) );
+ VERIFY( ! atomic_flag_test_explicit(&caf, memory_order_acquire) );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ return 0;
+}
#include <atomic>
#include <testsuite_hooks.h>
-int main()
+void
+test01()
{
using namespace std;
VERIFY( ! af.test() );
VERIFY( ! caf.test() );
}
+
+void
+test02()
+{
+ using namespace std;
+
+ atomic_flag af{true};
+ const atomic_flag& caf = af;
+
+ VERIFY( atomic_flag_test(&af) );
+ VERIFY( atomic_flag_test(&caf) );
+ af.clear(memory_order_release);
+ VERIFY( ! atomic_flag_test(&af) );
+ VERIFY( ! atomic_flag_test(&caf) );
+}
+
+int
+main()
+{
+ test01();
+ test02();
+ return 0;
+}