diff --git a/include/boost/unordered/detail/foa/concurrent_table.hpp b/include/boost/unordered/detail/foa/concurrent_table.hpp index 9111dadb..9f0b6908 100644 --- a/include/boost/unordered/detail/foa/concurrent_table.hpp +++ b/include/boost/unordered/detail/foa/concurrent_table.hpp @@ -310,6 +310,15 @@ public: using allocator_type=typename super::allocator_type; using size_type=typename super::size_type; +private: + template + using enable_if_is_value_type=typename std::enable_if< + !std::is_same::value&& + std::is_same::value, + T + >::type; + +public: concurrent_table( std::size_t n=default_bucket_count,const Hash& h_=Hash(), const Pred& pred_=Pred(),const Allocator& al_=Allocator()): @@ -358,6 +367,12 @@ public: return visit_impl(group_shared{},x,std::forward(f)); } + template + BOOST_FORCEINLINE std::size_t cvisit(const Key& x,F&& f)const + { + return visit(x,std::forward(f)); + } + template std::size_t visit_all(F&& f) { return visit_all_impl(group_exclusive{},std::forward(f)); @@ -368,6 +383,11 @@ public: return visit_all_impl(group_shared{},std::forward(f)); } + template std::size_t cvisit_all(F&& f)const + { + return visit_all(std::forward(f)); + } + #if defined(BOOST_UNORDERED_PARALLEL_ALGORITHMS) template void visit_all(ExecutionPolicy&& policy,F&& f) @@ -384,6 +404,12 @@ public: group_shared{}, std::forward(policy),std::forward(f)); } + + template + void cvisit_all(ExecutionPolicy&& policy,F&& f)const + { + visit_all(std::forward(policy),std::forward(f)); + } #endif bool empty()const noexcept{return size()==0;} @@ -433,6 +459,14 @@ public: try_emplace_args_t{},std::forward(x),std::forward(args)...); } + template + BOOST_FORCEINLINE bool try_emplace_or_cvisit(Key&& x,F&& f,Args&&... args) + { + return emplace_or_visit_impl( + group_shared{},std::forward(f), + try_emplace_args_t{},std::forward(x),std::forward(args)...); + } + template BOOST_FORCEINLINE bool emplace_or_visit(F&& f,Args&&... args) { @@ -440,12 +474,25 @@ public: group_exclusive{},std::forward(f),std::forward(args)...); } + template + BOOST_FORCEINLINE bool emplace_or_cvisit(F&& f,Args&&... args) + { + return construct_and_emplace_or_visit( + group_shared{},std::forward(f),std::forward(args)...); + } + template BOOST_FORCEINLINE bool insert_or_visit(const init_type& x,F&& f) { return emplace_or_visit_impl(group_exclusive{},std::forward(f),x); } + template + BOOST_FORCEINLINE bool insert_or_cvisit(const init_type& x,F&& f) + { + return emplace_or_visit_impl(group_shared{},std::forward(f),x); + } + template BOOST_FORCEINLINE bool insert_or_visit(init_type&& x,F&& f) { @@ -453,31 +500,45 @@ public: group_exclusive{},std::forward(f),std::move(x)); } + template + BOOST_FORCEINLINE bool insert_or_cvisit(init_type&& x,F&& f) + { + return emplace_or_visit_impl( + group_shared{},std::forward(f),std::move(x)); + } + /* SFINAE tilts call ambiguities in favor of init_type */ template BOOST_FORCEINLINE auto insert_or_visit(const Value& x,F&& f) - ->typename std::enable_if< - !std::is_same::value&& - std::is_same::value, - bool - >::type + ->enable_if_is_value_type { return emplace_or_visit_impl(group_exclusive{},std::forward(f),x); } + template + BOOST_FORCEINLINE auto insert_or_cvisit(const Value& x,F&& f) + ->enable_if_is_value_type + { + return emplace_or_visit_impl(group_shared{},std::forward(f),x); + } + template BOOST_FORCEINLINE auto insert_or_visit(Value&& x,F&& f) - ->typename std::enable_if< - !std::is_same::value&& - std::is_same::value, - bool - >::type + ->enable_if_is_value_type { return emplace_or_visit_impl( group_exclusive{},std::forward(f),std::move(x)); } + template + BOOST_FORCEINLINE auto insert_or_cvisit(Value&& x,F&& f) + ->enable_if_is_value_type + { + return emplace_or_visit_impl( + group_shared{},std::forward(f),std::move(x)); + } + template BOOST_FORCEINLINE std::size_t erase(Key&& x) {