refactored insert overloads

This commit is contained in:
joaquintides
2022-10-21 10:01:51 +02:00
parent 703f8d1065
commit 1d553447a0

View File

@ -1084,43 +1084,6 @@ private:
static constexpr bool has_mutable_iterator=
!std::is_same<key_type,value_type>::value;
template<
typename T,
typename RawT=typename std::remove_cv<
typename std::remove_reference<T>::type>::type
>
using value_from_return_type=typename std::conditional<
std::is_same<RawT,init_type>::value||std::is_same<RawT,value_type>::value,
T,
typename std::conditional<
std::is_convertible<T,init_type&&>::value,
init_type,
typename std::conditional<
std::is_convertible<T,value_type&&>::value,
value_type,
typename std::conditional<
std::is_convertible<T,const init_type&>::value,
const init_type&,
typename std::conditional<
std::is_convertible<T,const value_type&>::value,
const value_type&,
void
>::type
>::type
>::type
>::type
>::type;
template<
typename T,
typename std::enable_if<
!std::is_void<value_from_return_type<T&&>>::value>::type* =nullptr
>
static inline value_from_return_type<T&&> value_from(T&& x)
{
return std::forward<T>(x);
}
public:
using hasher=Hash;
using key_equal=Pred;
@ -1306,17 +1269,21 @@ public:
std::forward_as_tuple(std::forward<Args>(args)...));
}
template<typename T>
BOOST_FORCEINLINE auto insert(T&& x)
->decltype(value_from(std::forward<T>(x)),std::pair<iterator,bool>())
{
return emplace_impl(value_from(std::forward<T>(x)));
}
BOOST_FORCEINLINE std::pair<iterator,bool>
insert(const init_type& x){return emplace_impl(x);}
BOOST_FORCEINLINE std::pair<iterator,bool> insert(init_type&& x)
{
return emplace_impl(std::move(x));
}
BOOST_FORCEINLINE std::pair<iterator,bool>
insert(init_type&& x){return emplace_impl(std::move(x));}
/* template<typename=void> tilts call ambiguities in favor of init_type */
template<typename=void>
BOOST_FORCEINLINE std::pair<iterator,bool>
insert(const value_type& x){return emplace_impl(x);}
template<typename=void>
BOOST_FORCEINLINE std::pair<iterator,bool>
insert(value_type&& x){return emplace_impl(std::move(x));}
template<
bool dependent_value=false,