Remove unnecessary value_type conversion by expanding overloads for value_from()

This commit is contained in:
Christian Mazakas
2022-10-20 08:43:42 -07:00
parent 0ac4aeca50
commit c1d5902911
2 changed files with 19 additions and 2 deletions

View File

@ -1499,13 +1499,30 @@ private:
template<
typename T,
typename std::enable_if<!is_init_or_value_type<T>::value>::type* =nullptr
typename Ty=typename std::decay<T>::type,
typename std::enable_if<
!is_init_or_value_type<T>::value&&
std::is_convertible<Ty,init_type>::value
>::type* =nullptr
>
static inline init_type value_from(T&& x)
{
return std::forward<T>(x);
}
template<
typename T,
typename Ty=typename std::decay<T>::type,
typename std::enable_if<
!is_init_or_value_type<T>::value&&
!std::is_convertible<Ty,init_type>::value
>::type* =nullptr
>
static inline value_type value_from(T&& x)
{
return std::forward<T>(x);
}
template<typename T>
static inline auto key_from(const T& x)
->decltype(type_policy::extract(x))

View File

@ -239,7 +239,7 @@ namespace boost {
void insert(InputIterator first, InputIterator last)
{
for (auto pos = first; pos != last; ++pos) {
table_.insert(value_type(*pos));
table_.insert(*pos);
}
}