diff --git a/include/boost/unordered/detail/foa.hpp b/include/boost/unordered/detail/foa.hpp index a120e7da..df9dba2b 100644 --- a/include/boost/unordered/detail/foa.hpp +++ b/include/boost/unordered/detail/foa.hpp @@ -1299,6 +1299,7 @@ public: > void erase(iterator pos)noexcept{return erase(const_iterator(pos));} + BOOST_FORCEINLINE void erase(const_iterator pos)noexcept { destroy_element(pos.p); @@ -1307,6 +1308,7 @@ public: } template + BOOST_FORCEINLINE auto erase(Key&& x) -> typename std::enable_if< !std::is_convertible::value&& !std::is_convertible::value, std::size_t>::type diff --git a/include/boost/unordered/unordered_flat_map.hpp b/include/boost/unordered/unordered_flat_map.hpp index aa39fcfd..5d4fc28f 100644 --- a/include/boost/unordered/unordered_flat_map.hpp +++ b/include/boost/unordered/unordered_flat_map.hpp @@ -26,6 +26,12 @@ namespace boost { namespace unordered { + +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable : 4714) /* marked as __forceinline not inlined */ +#endif + template class unordered_flat_map { @@ -220,7 +226,7 @@ namespace boost { void clear() noexcept { table_.clear(); } template - auto insert(Ty&& value) + BOOST_FORCEINLINE auto insert(Ty&& value) -> decltype(table_.insert(std::forward(value))) { return table_.insert(std::forward(value)); @@ -232,19 +238,19 @@ namespace boost { } template - auto insert(const_iterator, Ty&& value) + BOOST_FORCEINLINE auto insert(const_iterator, Ty&& value) -> decltype(table_.insert(std::forward(value)).first) { return table_.insert(std::forward(value)).first; } - iterator insert(const_iterator, init_type&& value) + BOOST_FORCEINLINE iterator insert(const_iterator, init_type&& value) { return table_.insert(std::move(value)).first; } template - void insert(InputIterator first, InputIterator last) + BOOST_FORCEINLINE void insert(InputIterator first, InputIterator last) { for (auto pos = first; pos != last; ++pos) { table_.emplace(*pos); @@ -292,44 +298,52 @@ namespace boost { .first; } - template std::pair emplace(Args&&... args) + template + BOOST_FORCEINLINE std::pair emplace(Args&&... args) { return table_.emplace(std::forward(args)...); } template - iterator emplace_hint(const_iterator, Args&&... args) + BOOST_FORCEINLINE iterator emplace_hint(const_iterator, Args&&... args) { - return this->emplace(std::forward(args)...).first; + return table_.emplace(std::forward(args)...).first; } template - std::pair try_emplace(key_type const& key, Args&&... args) + BOOST_FORCEINLINE std::pair try_emplace( + key_type const& key, Args&&... args) { return table_.try_emplace(key, std::forward(args)...); } template - std::pair try_emplace(key_type&& key, Args&&... args) + BOOST_FORCEINLINE std::pair try_emplace( + key_type&& key, Args&&... args) { return table_.try_emplace(std::move(key), std::forward(args)...); } template - iterator try_emplace(const_iterator, key_type const& key, Args&&... args) + BOOST_FORCEINLINE iterator try_emplace( + const_iterator, key_type const& key, Args&&... args) { return table_.try_emplace(key, std::forward(args)...).first; } template - iterator try_emplace(const_iterator, key_type&& key, Args&&... args) + BOOST_FORCEINLINE iterator try_emplace( + const_iterator, key_type&& key, Args&&... args) { return table_.try_emplace(std::move(key), std::forward(args)...) .first; } - void erase(iterator pos) { table_.erase(pos); } - void erase(const_iterator pos) { return table_.erase(pos); } + BOOST_FORCEINLINE void erase(iterator pos) { table_.erase(pos); } + BOOST_FORCEINLINE void erase(const_iterator pos) + { + return table_.erase(pos); + } iterator erase(const_iterator first, const_iterator last) { while (first != last) { @@ -338,10 +352,13 @@ namespace boost { return iterator{detail::foa::const_iterator_cast_tag{}, last}; } - size_type erase(key_type const& key) { return table_.erase(key); } + BOOST_FORCEINLINE size_type erase(key_type const& key) + { + return table_.erase(key); + } template - typename std::enable_if< + BOOST_FORCEINLINE typename std::enable_if< detail::transparent_non_iterable::value, size_type>::type erase(K const& key) @@ -591,6 +608,11 @@ namespace boost { { return erase_if(map.table_, pred); } + +#if defined(BOOST_MSVC) +#pragma warning(pop) /* C4714 */ +#endif + } // namespace unordered } // namespace boost diff --git a/include/boost/unordered/unordered_flat_set.hpp b/include/boost/unordered/unordered_flat_set.hpp index a58151bb..1950dfb3 100644 --- a/include/boost/unordered/unordered_flat_set.hpp +++ b/include/boost/unordered/unordered_flat_set.hpp @@ -24,6 +24,12 @@ namespace boost { namespace unordered { + +#if defined(BOOST_MSVC) +#pragma warning(push) +#pragma warning(disable : 4714) /* marked as __forceinline not inlined */ +#endif + template class unordered_flat_set { @@ -201,22 +207,23 @@ namespace boost { void clear() noexcept { table_.clear(); } - std::pair insert(value_type const& value) + BOOST_FORCEINLINE std::pair insert( + value_type const& value) { return table_.insert(value); } - std::pair insert(value_type&& value) + BOOST_FORCEINLINE std::pair insert(value_type&& value) { return table_.insert(std::move(value)); } - iterator insert(const_iterator, value_type const& value) + BOOST_FORCEINLINE iterator insert(const_iterator, value_type const& value) { return table_.insert(value).first; } - iterator insert(const_iterator, value_type&& value) + BOOST_FORCEINLINE iterator insert(const_iterator, value_type&& value) { return table_.insert(std::move(value)).first; } @@ -234,18 +241,22 @@ namespace boost { this->insert(ilist.begin(), ilist.end()); } - template std::pair emplace(Args&&... args) + template + BOOST_FORCEINLINE std::pair emplace(Args&&... args) { return table_.emplace(std::forward(args)...); } template - iterator emplace_hint(const_iterator, Args&&... args) + BOOST_FORCEINLINE iterator emplace_hint(const_iterator, Args&&... args) { - return this->emplace(std::forward(args)...).first; + return table_.emplace(std::forward(args)...).first; } - void erase(const_iterator pos) { return table_.erase(pos); } + BOOST_FORCEINLINE void erase(const_iterator pos) + { + return table_.erase(pos); + } iterator erase(const_iterator first, const_iterator last) { while (first != last) { @@ -254,10 +265,13 @@ namespace boost { return iterator{detail::foa::const_iterator_cast_tag{}, last}; } - size_type erase(key_type const& key) { return table_.erase(key); } + BOOST_FORCEINLINE size_type erase(key_type const& key) + { + return table_.erase(key); + } template - typename std::enable_if< + BOOST_FORCEINLINE typename std::enable_if< detail::transparent_non_iterable::value, size_type>::type erase(K const& key) @@ -469,6 +483,11 @@ namespace boost { { return erase_if(set.table_, pred); } + +#if defined(BOOST_MSVC) +#pragma warning(pop) /* C4714 */ +#endif + } // namespace unordered } // namespace boost