summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/thread/thread.mutex/thread.once
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2015-06-13 02:23:00 +0000
committerEric Fiselier <eric@efcs.ca>2015-06-13 02:23:00 +0000
commit793f59e7676ca997ffe0a919d9135bb3dcad7ecf (patch)
treeec0e5e92f17d9ddd4962605e1cf90c1b87e8c8e1 /libcxx/test/std/thread/thread.mutex/thread.once
parent678ad2f9daeed8b40c3272e67e8837b4629b72be (diff)
downloadbcm5719-llvm-793f59e7676ca997ffe0a919d9135bb3dcad7ecf.tar.gz
bcm5719-llvm-793f59e7676ca997ffe0a919d9135bb3dcad7ecf.zip
LWG2442: call_once() shouldn't DECAY_COPY(). Patch from K-Ballo.
This patch fixes LWG issue 2422 by removing the DECAY_COPY from call once. The review can be found here: http://reviews.llvm.org/D10191 llvm-svn: 239654
Diffstat (limited to 'libcxx/test/std/thread/thread.mutex/thread.once')
-rw-r--r--libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp48
1 files changed, 47 insertions, 1 deletions
diff --git a/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp b/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
index 5395c85495f..89b99348459 100644
--- a/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
+++ b/libcxx/test/std/thread/thread.mutex/thread.once/thread.once.callonce/call_once.pass.cpp
@@ -14,7 +14,7 @@
// struct once_flag;
// template<class Callable, class ...Args>
-// void call_once(once_flag& flag, Callable func, Args&&... args);
+// void call_once(once_flag& flag, Callable&& func, Args&&... args);
#include <mutex>
#include <thread>
@@ -153,6 +153,35 @@ public:
}
};
+class NonCopyable
+{
+#if !defined(__clang__)
+ // GCC 4.8 complains about the following being private
+public:
+ NonCopyable(const NonCopyable&)
+ {
+ }
+#else
+ NonCopyable(const NonCopyable&);
+#endif
+public:
+ NonCopyable() {}
+
+ void operator()(int&) {}
+};
+
+#if __cplusplus >= 201103L
+// reference qualifiers on functions are a C++11 extension
+struct RefQual
+{
+ int lv_called, rv_called;
+
+ RefQual() : lv_called(0), rv_called(0) {}
+
+ void operator()() & { ++lv_called; }
+ void operator()() && { ++rv_called; }
+};
+#endif
#endif
int main()
@@ -204,5 +233,22 @@ int main()
std::once_flag f;
std::call_once(f, MoveOnly(), MoveOnly());
}
+ // check LWG2442: call_once() shouldn't DECAY_COPY()
+ {
+ std::once_flag f;
+ int i = 0;
+ std::call_once(f, NonCopyable(), i);
+ }
+#if __cplusplus >= 201103L
+// reference qualifiers on functions are a C++11 extension
+ {
+ std::once_flag f1, f2;
+ RefQual rq;
+ std::call_once(f1, rq);
+ assert(rq.lv_called == 1);
+ std::call_once(f2, std::move(rq));
+ assert(rq.rv_called == 1);
+ }
+#endif
#endif // _LIBCPP_HAS_NO_VARIADICS
}
OpenPOWER on IntegriCloud