OSDN Git Service

* include/std/mutex (call_once): Store closure in __once_functor
authorredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Nov 2011 22:26:15 +0000 (22:26 +0000)
committerredi <redi@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Nov 2011 22:26:15 +0000 (22:26 +0000)
as bound function wrapper might not be copyable.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181128 138bc75d-0d04-0410-961f-82ee72b054a4

libstdc++-v3/ChangeLog
libstdc++-v3/include/std/mutex

index b8c222b..1583ef0 100644 (file)
@@ -1,3 +1,8 @@
+2011-11-07  Jonathan Wakely  <jwakely.gcc@gmail.com>
+
+       * include/std/mutex (call_once): Store closure in __once_functor
+       as bound function wrapper might not be copyable.
+
 2011-11-07  Andrew MacLeod  <amacleod@redhat.com>
 
        * include/bits/atomic_base.h (atomic_thread_fence): Revert.
index bc2675b..69e26e6 100644 (file)
@@ -810,8 +810,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       __once_call = &__once_call_impl<decltype(__bound_functor)>;
 #else
       unique_lock<mutex> __functor_lock(__get_once_mutex());
-      __once_functor = std::__bind_simple(std::forward<_Callable>(__f),
+      auto __callable = std::__bind_simple(std::forward<_Callable>(__f),
           std::forward<_Args>(__args)...);
+      __once_functor = [&]() { __callable(); };
       __set_once_functor_lock_ptr(&__functor_lock);
 #endif