Tried to fix gcc/clang problem like how to pass argument pack to lambda function
authorkhizmax <khizmax@gmail.com>
Thu, 5 Mar 2015 14:59:42 +0000 (17:59 +0300)
committerkhizmax <khizmax@gmail.com>
Thu, 5 Mar 2015 14:59:42 +0000 (17:59 +0300)
cds/container/bronson_avltree_map_rcu.h

index 8278c6e678b87262a1b99f389b11f9b0c33dcf7a..f36f53d22b7d73ef5315a0499b32f246fe64fc9e 100644 (file)
@@ -236,19 +236,24 @@ namespace cds { namespace container {
         template <typename K, typename... Args>
         bool emplace( K&& key, Args&&... args )
         {
-            auto helper = []( Args&&... args ) -> mapped_type *
+#       if CDS_COMPILER != CDS_COMPILER_MSVC
+            auto helper = []( typename std::decay<Args>::type&&... args ) -> mapped_type *
                             {
-                                return cxx_allocator().New( std::forward<Args>(args)...);
+                                return cxx_allocator().New( std::move(args)...);
                             };
+#       endif
             
             return base_class::do_update( key, key_comparator(),
-                [=]( node_type * pNode ) -> mapped_type * 
+                [&]( node_type * pNode ) -> mapped_type * 
                 {
                     assert( pNode->m_pValue.load( memory_model::memory_order_relaxed ) == nullptr );
                     CDS_UNUSED( pNode );
-                    return helper( args... );
+#       if CDS_COMPILER == CDS_COMPILER_MSVC
+                    return cxx_allocator().New( std::forward<Args>(args)...);
+#       else
                     // gcc/clang error: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47226
-                    //return cxx_allocator().New( std::forward<Args>(args)...);
+                    return helper( args... );
+#       endif
                 },
                 update_flags::allow_insert
             ) == update_flags::result_inserted;