mirror of
https://github.com/boostorg/unordered.git
synced 2025-11-08 19:51:54 +01:00
Initial implementation of template deduction guides
This commit is contained in:
@@ -193,6 +193,18 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
|
||||
|
||||
#if !defined(BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES)
|
||||
#if BOOST_COMP_CLANG && __cplusplus >= 201703
|
||||
#define BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES 1
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES)
|
||||
#define BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES 0
|
||||
#endif
|
||||
|
||||
namespace boost {
|
||||
namespace unordered {
|
||||
namespace iterator_detail {
|
||||
|
||||
@@ -831,6 +831,81 @@ namespace boost {
|
||||
#endif
|
||||
}; // class template unordered_map
|
||||
|
||||
#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
|
||||
|
||||
namespace detail {
|
||||
template <typename T>
|
||||
using iter_key_t =
|
||||
typename std::iterator_traits<T>::value_type::first_type;
|
||||
template <typename T>
|
||||
using iter_val_t =
|
||||
typename std::iterator_traits<T>::value_type::second_type;
|
||||
template <typename T>
|
||||
using iter_to_alloc_t =
|
||||
typename std::pair<iter_key_t<T> const, iter_val_t<T> >;
|
||||
}
|
||||
|
||||
template <class InputIterator,
|
||||
class Hash =
|
||||
boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
class Pred =
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
class Allocator = std::allocator<
|
||||
boost::unordered::detail::iter_to_alloc_t<InputIterator> > >
|
||||
unordered_map(InputIterator, InputIterator,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_map<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>, Hash, Pred,
|
||||
Allocator>;
|
||||
|
||||
template <class Key, class T, class Hash = boost::hash<Key>,
|
||||
class Pred = std::equal_to<Key>,
|
||||
class Allocator = std::allocator<std::pair<const Key, T> > >
|
||||
unordered_map(std::initializer_list<std::pair<const Key, T> >,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_map<Key, T, Hash, Pred, Allocator>;
|
||||
|
||||
template <class InputIterator, class Allocator>
|
||||
unordered_map(InputIterator, InputIterator, std::size_t, Allocator)
|
||||
->unordered_map<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>,
|
||||
boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
Allocator>;
|
||||
|
||||
template <class InputIterator, class Allocator>
|
||||
unordered_map(InputIterator, InputIterator, Allocator)
|
||||
->unordered_map<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>,
|
||||
boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
Allocator>;
|
||||
|
||||
template <class InputIterator, class Hash, class Allocator>
|
||||
unordered_map(InputIterator, InputIterator, std::size_t, Hash, Allocator)
|
||||
->unordered_map<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>, Hash,
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
Allocator>;
|
||||
|
||||
template <class Key, class T, typename Allocator>
|
||||
unordered_map(
|
||||
std::initializer_list<std::pair<const Key, T> >, std::size_t, Allocator)
|
||||
->unordered_map<Key, T, boost::hash<Key>, std::equal_to<Key>, Allocator>;
|
||||
|
||||
template <class Key, class T, typename Allocator>
|
||||
unordered_map(std::initializer_list<std::pair<const Key, T> >, Allocator)
|
||||
->unordered_map<Key, T, boost::hash<Key>, std::equal_to<Key>, Allocator>;
|
||||
|
||||
template <class Key, class T, class Hash, class Allocator>
|
||||
unordered_map(std::initializer_list<std::pair<const Key, T> >, std::size_t,
|
||||
Hash, Allocator)
|
||||
->unordered_map<Key, T, Hash, std::equal_to<Key>, Allocator>;
|
||||
|
||||
#endif
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
class unordered_multimap
|
||||
{
|
||||
@@ -1363,6 +1438,73 @@ namespace boost {
|
||||
#endif
|
||||
}; // class template unordered_multimap
|
||||
|
||||
#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
|
||||
|
||||
template <class InputIterator,
|
||||
class Hash =
|
||||
boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
class Pred =
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
class Allocator = std::allocator<
|
||||
boost::unordered::detail::iter_to_alloc_t<InputIterator> > >
|
||||
unordered_multimap(InputIterator, InputIterator,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_multimap<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>, Hash, Pred,
|
||||
Allocator>;
|
||||
|
||||
template <class Key, class T, class Hash = boost::hash<Key>,
|
||||
class Pred = std::equal_to<Key>,
|
||||
class Allocator = std::allocator<std::pair<const Key, T> > >
|
||||
unordered_multimap(std::initializer_list<std::pair<const Key, T> >,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_multimap<Key, T, Hash, Pred, Allocator>;
|
||||
|
||||
template <class InputIterator, class Allocator>
|
||||
unordered_multimap(InputIterator, InputIterator, std::size_t, Allocator)
|
||||
->unordered_multimap<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>,
|
||||
boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
Allocator>;
|
||||
|
||||
template <class InputIterator, class Allocator>
|
||||
unordered_multimap(InputIterator, InputIterator, Allocator)
|
||||
->unordered_multimap<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>,
|
||||
boost::hash<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
Allocator>;
|
||||
|
||||
template <class InputIterator, class Hash, class Allocator>
|
||||
unordered_multimap(
|
||||
InputIterator, InputIterator, std::size_t, Hash, Allocator)
|
||||
->unordered_multimap<boost::unordered::detail::iter_key_t<InputIterator>,
|
||||
boost::unordered::detail::iter_val_t<InputIterator>, Hash,
|
||||
std::equal_to<boost::unordered::detail::iter_key_t<InputIterator> >,
|
||||
Allocator>;
|
||||
|
||||
template <class Key, class T, typename Allocator>
|
||||
unordered_multimap(
|
||||
std::initializer_list<std::pair<const Key, T> >, std::size_t, Allocator)
|
||||
->unordered_multimap<Key, T, boost::hash<Key>, std::equal_to<Key>,
|
||||
Allocator>;
|
||||
|
||||
template <class Key, class T, typename Allocator>
|
||||
unordered_multimap(
|
||||
std::initializer_list<std::pair<const Key, T> >, Allocator)
|
||||
->unordered_multimap<Key, T, boost::hash<Key>, std::equal_to<Key>,
|
||||
Allocator>;
|
||||
|
||||
template <class Key, class T, class Hash, class Allocator>
|
||||
unordered_multimap(std::initializer_list<std::pair<const Key, T> >,
|
||||
std::size_t, Hash, Allocator)
|
||||
->unordered_multimap<Key, T, Hash, std::equal_to<Key>, Allocator>;
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <class K, class T, class H, class P, class A>
|
||||
|
||||
@@ -545,6 +545,52 @@ namespace boost {
|
||||
#endif
|
||||
}; // class template unordered_set
|
||||
|
||||
#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
|
||||
|
||||
template <class InputIterator,
|
||||
class Hash =
|
||||
boost::hash<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
class Pred =
|
||||
std::equal_to<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
class Allocator = std::allocator<
|
||||
typename std::iterator_traits<InputIterator>::value_type> >
|
||||
unordered_set(InputIterator, InputIterator,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_set<typename std::iterator_traits<InputIterator>::value_type,
|
||||
Hash, Pred, Allocator>;
|
||||
|
||||
template <class T, class Hash = boost::hash<T>,
|
||||
class Pred = std::equal_to<T>, class Allocator = std::allocator<T> >
|
||||
unordered_set(std::initializer_list<T>,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_set<T, Hash, Pred, Allocator>;
|
||||
|
||||
template <class InputIterator, class Allocator>
|
||||
unordered_set(InputIterator, InputIterator, std::size_t, Allocator)
|
||||
->unordered_set<typename std::iterator_traits<InputIterator>::value_type,
|
||||
boost::hash<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
std::equal_to<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
Allocator>;
|
||||
|
||||
template <class InputIterator, class Hash, class Allocator>
|
||||
unordered_set(InputIterator, InputIterator, std::size_t, Hash, Allocator)
|
||||
->unordered_set<typename std::iterator_traits<InputIterator>::value_type,
|
||||
Hash,
|
||||
std::equal_to<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
Allocator>;
|
||||
|
||||
template <class T, class Allocator>
|
||||
unordered_set(std::initializer_list<T>, std::size_t, Allocator)
|
||||
->unordered_set<T, boost::hash<T>, std::equal_to<T>, Allocator>;
|
||||
|
||||
template <class T, class Hash, class Allocator>
|
||||
unordered_set(std::initializer_list<T>, std::size_t, Hash, Allocator)
|
||||
->unordered_set<T, Hash, std::equal_to<T>, Allocator>;
|
||||
|
||||
#endif
|
||||
|
||||
template <class T, class H, class P, class A> class unordered_multiset
|
||||
{
|
||||
#if defined(BOOST_UNORDERED_USE_MOVE)
|
||||
@@ -1049,6 +1095,55 @@ namespace boost {
|
||||
#endif
|
||||
}; // class template unordered_multiset
|
||||
|
||||
#if BOOST_UNORDERED_TEMPLATE_DEDUCTION_GUIDES
|
||||
|
||||
template <class InputIterator,
|
||||
class Hash =
|
||||
boost::hash<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
class Pred =
|
||||
std::equal_to<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
class Allocator = std::allocator<
|
||||
typename std::iterator_traits<InputIterator>::value_type> >
|
||||
unordered_multiset(InputIterator, InputIterator,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_multiset<
|
||||
typename std::iterator_traits<InputIterator>::value_type, Hash, Pred,
|
||||
Allocator>;
|
||||
|
||||
template <class T, class Hash = boost::hash<T>,
|
||||
class Pred = std::equal_to<T>, class Allocator = std::allocator<T> >
|
||||
unordered_multiset(std::initializer_list<T>,
|
||||
std::size_t = boost::unordered::detail::default_bucket_count,
|
||||
Hash = Hash(), Pred = Pred(), Allocator = Allocator())
|
||||
->unordered_multiset<T, Hash, Pred, Allocator>;
|
||||
|
||||
template <class InputIterator, class Allocator>
|
||||
unordered_multiset(InputIterator, InputIterator, std::size_t, Allocator)
|
||||
->unordered_multiset<
|
||||
typename std::iterator_traits<InputIterator>::value_type,
|
||||
boost::hash<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
std::equal_to<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
Allocator>;
|
||||
|
||||
template <class InputIterator, class Hash, class Allocator>
|
||||
unordered_multiset(
|
||||
InputIterator, InputIterator, std::size_t, Hash, Allocator)
|
||||
->unordered_multiset<
|
||||
typename std::iterator_traits<InputIterator>::value_type, Hash,
|
||||
std::equal_to<typename std::iterator_traits<InputIterator>::value_type>,
|
||||
Allocator>;
|
||||
|
||||
template <class T, class Allocator>
|
||||
unordered_multiset(std::initializer_list<T>, std::size_t, Allocator)
|
||||
->unordered_multiset<T, boost::hash<T>, std::equal_to<T>, Allocator>;
|
||||
|
||||
template <class T, class Hash, class Allocator>
|
||||
unordered_multiset(std::initializer_list<T>, std::size_t, Hash, Allocator)
|
||||
->unordered_multiset<T, Hash, std::equal_to<T>, Allocator>;
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
template <class T, class H, class P, class A>
|
||||
unordered_set<T, H, P, A>::unordered_set()
|
||||
|
||||
Reference in New Issue
Block a user