2019-10-23 Jonathan Wakely <jwakely@redhat.com>
+ * include/ext/pb_ds/detail/bin_search_tree_/bin_search_tree_.hpp:
+ Use detail::rebind_traits.
+ * include/ext/pb_ds/detail/bin_search_tree_/node_iterators.hpp:
+ Likewise.
+ * include/ext/pb_ds/detail/bin_search_tree_/traits.hpp: Likewise.
+ * include/ext/pb_ds/detail/binary_heap_/binary_heap_.hpp: Likewise.
+ * include/ext/pb_ds/detail/binary_heap_/entry_cmp.hpp: Likewise.
+ * include/ext/pb_ds/detail/binary_heap_/entry_pred.hpp: Likewise.
+ * include/ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp:
+ Likewise.
+ * include/ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp:
+ Likewise.
+ * include/ext/pb_ds/detail/branch_policy/branch_policy.hpp: Likewise.
+ * include/ext/pb_ds/detail/cc_hash_table_map_/cc_ht_map_.hpp: Likewise.
+ * include/ext/pb_ds/detail/cond_dealtor.hpp: Likewise.
+ * include/ext/pb_ds/detail/eq_fn/hash_eq_fn.hpp (has_eq_fn): Likewise.
+ * include/ext/pb_ds/detail/gp_hash_table_map_/gp_ht_map_.hpp: Likewise.
+ * include/ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp: Likewise.
+ * include/ext/pb_ds/detail/hash_fn/ranged_probe_fn.hpp: Likewise.
+ * include/ext/pb_ds/detail/left_child_next_sibling_heap_/
+ left_child_next_sibling_heap_.hpp: Likewise.
+ * include/ext/pb_ds/detail/left_child_next_sibling_heap_/node.hpp:
+ Likewise.
+ * include/ext/pb_ds/detail/left_child_next_sibling_heap_/
+ point_const_iterator.hpp: Likewise.
+ * include/ext/pb_ds/detail/list_update_map_/lu_map_.hpp: Likewise.
+ * include/ext/pb_ds/detail/ov_tree_map_/
+ constructors_destructor_fn_imps.hpp: Likewise.
+ * include/ext/pb_ds/detail/ov_tree_map_/node_iterators.hpp: Likewise.
+ * include/ext/pb_ds/detail/ov_tree_map_/ov_tree_map_.hpp: Likewise.
+ * include/ext/pb_ds/detail/pairing_heap_/pairing_heap_.hpp: Likewise.
+ * include/ext/pb_ds/detail/pat_trie_/pat_trie_.hpp: Likewise.
+ * include/ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp: Likewise.
+ * include/ext/pb_ds/detail/rb_tree_map_/node.hpp: Likewise.
+ * include/ext/pb_ds/detail/rc_binomial_heap_/rc.hpp: Likewise.
+ * include/ext/pb_ds/detail/splay_tree_/node.hpp: Likewise.
+ * include/ext/pb_ds/detail/thin_heap_/thin_heap_.hpp: Likewise.
+ * include/ext/pb_ds/detail/trie_policy/sample_trie_access_traits.hpp:
+ Likewise.
+ * include/ext/pb_ds/detail/type_utils.hpp: Fix typo in comment.
+ * include/ext/pb_ds/detail/types_traits.hpp (stored_value): Add
+ bool parameter to control whether the hash value is stored.
+ (select_base_type): New class template and partial specialization.
+ (maybe_null_type): Likewise.
+ (rebind_traits): New class template.
+ (type_base): Remove four nearly identical specializations.
+ (type_dispatch): Remove.
+ (type_traits): Use select_base_type and maybe_null_type instead of
+ type_base to control differences between specializations.
+ * include/ext/pb_ds/list_update_policy.hpp: Use detail::rebind_traits.
+ * include/ext/pb_ds/priority_queue.hpp: Likewise.
+ * include/ext/pb_ds/tree_policy.hpp: Likewise.
+ * include/ext/pb_ds/trie_policy.hpp: Likewise.
+
* include/backward/hash_set (hash_set): Use __alloc_traits.
* include/backward/hashtable.h (_Hashtable): Likewise.
* include/ext/alloc_traits.h (__alloc_traits::allocate): Add overload
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
debug_map_base<Key, eq_by_less<Key, Cmp_Fn>, \
- typename _Alloc::template rebind<Key>::other::const_reference>
+ typename rebind_traits<_Alloc, Key>::const_reference>
#endif
#ifdef PB_DS_TREE_TRACE
public Node_And_It_Traits::node_update
{
typedef Node_And_It_Traits traits_type;
+ typedef rebind_traits<_Alloc, typename traits_type::node>
+ node_alloc_traits;
protected:
typedef PB_DS_BIN_TREE_TRAITS_BASE traits_base;
typedef
- typename _Alloc::template rebind<typename traits_type::node>::other
- node_allocator;
+ typename node_alloc_traits::allocator_type node_allocator;
- typedef typename node_allocator::value_type node;
- typedef typename node_allocator::pointer node_pointer;
+ typedef typename node_alloc_traits::value_type node;
+ typedef typename node_alloc_traits::pointer node_pointer;
typedef typename traits_type::null_node_update_pointer
null_node_update_pointer;
class bin_search_tree_const_node_it_
{
private:
- typedef
- typename _Alloc::template rebind<
- Node>::other::pointer
- node_pointer;
+ typedef typename rebind_traits<_Alloc, Node>::pointer node_pointer;
public:
/// Category.
typedef typename Node::metadata_type metadata_type;
/// Const metadata reference type.
- typedef
- typename _Alloc::template rebind<metadata_type>::other::const_reference
- metadata_const_reference;
+ typedef typename rebind_traits<_Alloc, metadata_type>::const_reference
+ metadata_const_reference;
bin_search_tree_const_node_it_(const node_pointer p_nd = 0)
: public PB_DS_TREE_CONST_NODE_ITERATOR_CLASS_C_DEC
{
private:
- typedef
- typename _Alloc::template rebind<
- Node>::other::pointer
- node_pointer;
+ typedef typename rebind_traits<_Alloc, Node>::pointer node_pointer;
public:
/// Iterator's value type.
{
private:
typedef types_traits<Key, Mapped, _Alloc, false> type_traits;
+ typedef rebind_traits<_Alloc, Node> node_alloc_traits;
public:
typedef Node node;
typedef
bin_search_tree_const_it_<
- typename _Alloc::template rebind<
- node>::other::pointer,
+ typename node_alloc_traits::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
typename type_traits::const_pointer,
typedef
bin_search_tree_it_<
- typename _Alloc::template rebind<
- node>::other::pointer,
+ typename node_alloc_traits::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
typename type_traits::const_pointer,
typedef
bin_search_tree_const_it_<
- typename _Alloc::template rebind<
- node>::other::pointer,
+ typename node_alloc_traits::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
typename type_traits::const_pointer,
typedef
bin_search_tree_it_<
- typename _Alloc::template rebind<
- node>::other::pointer,
+ typename node_alloc_traits::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
typename type_traits::const_pointer,
{
private:
typedef types_traits<Key, null_type, _Alloc, false> type_traits;
+ typedef rebind_traits<_Alloc, Node> node_alloc_traits;
public:
typedef Node node;
typedef
bin_search_tree_const_it_<
- typename _Alloc::template rebind<
- node>::other::pointer,
+ typename node_alloc_traits::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
typename type_traits::const_pointer,
typedef
bin_search_tree_const_it_<
- typename _Alloc::template rebind<
- node>::other::pointer,
+ typename node_alloc_traits::pointer,
typename type_traits::value_type,
typename type_traits::pointer,
typename type_traits::const_pointer,
typedef integral_constant<int, simple_value> no_throw_copies_t;
- typedef typename _Alloc::template rebind<value_type> __rebind_v;
- typedef typename __rebind_v::other value_allocator;
+ typedef rebind_traits<_Alloc, value_type> __rebind_v;
+ typedef typename __rebind_v::allocator_type value_allocator;
public:
- typedef typename value_allocator::pointer pointer;
- typedef typename value_allocator::const_pointer const_pointer;
- typedef typename value_allocator::reference reference;
- typedef typename value_allocator::const_reference const_reference;
+ typedef typename __rebind_v::pointer pointer;
+ typedef typename __rebind_v::const_pointer const_pointer;
+ typedef typename __rebind_v::reference reference;
+ typedef typename __rebind_v::const_reference const_reference;
typedef typename __conditional_type<simple_value,
value_type, pointer>::__type
entry;
- typedef typename _Alloc::template rebind<entry>::other
+ typedef typename rebind_traits<_Alloc, entry>::allocator_type
entry_allocator;
- typedef typename entry_allocator::pointer entry_pointer;
+ typedef typename rebind_traits<_Alloc, entry>::pointer entry_pointer;
typedef binary_heap_point_const_iterator_<value_type, entry,
simple_value, _Alloc>
struct entry_cmp<_VTp, Cmp_Fn, _Alloc, false>
{
private:
- typedef typename _Alloc::template rebind<_VTp> __rebind_v;
+ typedef rebind_traits<_Alloc, _VTp> __rebind_v;
public:
- typedef typename __rebind_v::other::const_pointer entry;
+ typedef typename __rebind_v::const_pointer entry;
/// Compare plus entry.
struct type : public Cmp_Fn
struct entry_pred<_VTp, Pred, _Alloc, false>
{
private:
- typedef typename _Alloc::template rebind<_VTp> __rebind_v;
+ typedef rebind_traits<_Alloc, _VTp> __rebind_v;
public:
- typedef typename __rebind_v::other::const_pointer entry;
+ typedef typename __rebind_v::const_pointer entry;
struct type : public Pred
{
class binary_heap_point_const_iterator_
{
protected:
- typedef typename _Alloc::template rebind<Entry>::other::pointer entry_pointer;
+ typedef typename rebind_traits<_Alloc, Entry>::pointer entry_pointer;
public:
/// Category.
typedef Value_Type value_type;
/// Iterator's pointer type.
- typedef typename _Alloc::template rebind<value_type>::other::pointer
- pointer;
+ typedef typename rebind_traits<_Alloc, value_type>::pointer pointer;
/// Iterator's const pointer type.
- typedef
- typename _Alloc::template rebind<value_type>::other::const_pointer
- const_pointer;
+ typedef typename rebind_traits<_Alloc, value_type>::const_pointer
+ const_pointer;
/// Iterator's reference type.
- typedef
- typename _Alloc::template rebind<value_type>::other::reference
- reference;
+ typedef typename rebind_traits<_Alloc, value_type>::reference
+ reference;
/// Iterator's const reference type.
- typedef
- typename _Alloc::template rebind<value_type>::other::const_reference
- const_reference;
+ typedef typename rebind_traits<_Alloc, value_type>::const_reference
+ const_reference;
inline
binary_heap_point_const_iterator_(entry_pointer p_e) : m_p_e(p_e)
: public PB_DS_B_HEAP_BASE
{
private:
- typedef typename _Alloc::template rebind<Value_Type>::other __rebind_v;
+ typedef rebind_traits<_Alloc, Value_Type> __rebind_v;
typedef PB_DS_B_HEAP_BASE base_type;
protected:
#define PB_DS_BRANCH_POLICY_BASE_HPP
#include <ext/pb_ds/tag_and_trait.hpp>
+#include <ext/pb_ds/detail/types_traits.hpp>
namespace __gnu_pbds
{
typedef typename remove_const<value_type>::type rcvalue_type;
typedef typename remove_const<key_type>::type rckey_type;
- typedef typename _Alloc::template rebind<rcvalue_type>::other rebind_v;
- typedef typename _Alloc::template rebind<rckey_type>::other rebind_k;
+ typedef rebind_traits<_Alloc, rcvalue_type> rebind_v;
+ typedef rebind_traits<_Alloc, rckey_type> rebind_k;
typedef typename rebind_v::reference reference;
typedef typename rebind_v::const_reference const_reference;
typedef typename Node_CItr::value_type it_type;
typedef typename std::iterator_traits<it_type>::value_type value_type;
typedef typename remove_const<value_type>::type rcvalue_type;
- typedef typename _Alloc::template rebind<rcvalue_type>::other rebind_v;
+ typedef rebind_traits<_Alloc, rcvalue_type> rebind_v;
typedef typename rebind_v::reference reference;
typedef typename rebind_v::const_reference const_reference;
typedef typename rebind_v::const_pointer const_pointer;
#include <utility>
#include <iterator>
+#include <memory>
#include <ext/pb_ds/detail/cond_dealtor.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/detail/hash_fn/ranged_hash_fn.hpp>
#define PB_DS_CLASS_C_DEC \
PB_DS_CC_HASH_NAME<Key, Mapped, Hash_Fn, Eq_Fn, _Alloc, \
- Store_Hash, Comb_Hash_Fn, Resize_Policy>
+ Store_Hash, Comb_Hash_Fn, Resize_Policy>
#define PB_DS_HASH_EQ_FN_C_DEC \
hash_eq_fn<Key, Eq_Fn, _Alloc, Store_Hash>
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
debug_map_base<Key, Eq_Fn, \
- typename _Alloc::template rebind<Key>::other::const_reference>
+ typename rebind_traits<_Alloc, Key>::const_reference>
#endif
typename _Alloc,
bool Store_Hash,
typename Comb_Hash_Fn,
- typename Resize_Policy >
+ typename Resize_Policy>
class PB_DS_CC_HASH_NAME:
#ifdef _GLIBCXX_DEBUG
protected PB_DS_DEBUG_MAP_BASE_C_DEC,
struct entry : public traits_base::stored_data_type
{
- typename _Alloc::template rebind<entry>::other::pointer m_p_next;
+ typename rebind_traits<_Alloc, entry>::pointer m_p_next;
};
typedef cond_dealtor<entry, _Alloc> cond_dealtor_t;
- typedef typename _Alloc::template rebind<entry>::other entry_allocator;
- typedef typename entry_allocator::pointer entry_pointer;
- typedef typename entry_allocator::const_pointer const_entry_pointer;
- typedef typename entry_allocator::reference entry_reference;
- typedef typename entry_allocator::const_reference const_entry_reference;
+ typedef rebind_traits<_Alloc, entry> entry_traits;
+ typedef typename entry_traits::allocator_type entry_allocator;
+ typedef typename entry_traits::pointer entry_pointer;
+ typedef typename entry_traits::const_pointer const_entry_pointer;
+ typedef typename entry_traits::reference entry_reference;
+ typedef typename entry_traits::const_reference const_entry_reference;
- typedef typename _Alloc::template rebind<entry_pointer>::other entry_pointer_allocator;
- typedef typename entry_pointer_allocator::pointer entry_pointer_array;
+ typedef rebind_traits<_Alloc, entry_pointer> entry_pointer_traits;
+ typedef typename entry_pointer_traits::allocator_type entry_pointer_allocator;
+ typedef typename entry_pointer_traits::pointer entry_pointer_array;
typedef PB_DS_RANGED_HASH_FN_C_DEC ranged_hash_fn_base;
typedef PB_DS_HASH_EQ_FN_C_DEC hash_eq_fn_base;
#ifndef PB_DS_COND_DEALTOR_HPP
#define PB_DS_COND_DEALTOR_HPP
+#include <ext/pb_ds/detail/types_traits.hpp>
+
namespace __gnu_pbds
{
namespace detail
template<typename Entry, typename _Alloc>
class cond_dealtor
{
- typedef typename _Alloc::template rebind<Entry> __rebind_e;
+ typedef rebind_traits<_Alloc, Entry> alloc_traits;
public:
- typedef typename __rebind_e::other entry_allocator;
- typedef typename entry_allocator::pointer entry_pointer;
+ typedef typename alloc_traits::allocator_type entry_allocator;
+ typedef typename alloc_traits::pointer entry_pointer;
cond_dealtor(entry_pointer p_e)
: m_p_e(p_e), m_no_action_destructor(false) { }
/**
* @file hash_eq_fn.hpp
- * Contains 2 eqivalence functions, one employing a hash value,
+ * Contains 2 equivalence functions, one employing a hash value,
* and one ignoring it.
*/
#define PB_DS_HASH_EQ_FN_HPP
#include <utility>
+#include <ext/pb_ds/detail/types_traits.hpp>
#include <debug/debug.h>
namespace __gnu_pbds
struct hash_eq_fn<Key, Eq_Fn, _Alloc, false> : public Eq_Fn
{
typedef Eq_Fn eq_fn_base;
- typedef typename _Alloc::template rebind<Key>::other key_allocator;
- typedef typename key_allocator::const_reference key_const_reference;
+ typedef typename rebind_traits<_Alloc, Key>::const_reference
+ key_const_reference;
hash_eq_fn() { }
{
typedef typename _Alloc::size_type size_type;
typedef Eq_Fn eq_fn_base;
- typedef typename _Alloc::template rebind<Key>::other key_allocator;
- typedef typename key_allocator::const_reference key_const_reference;
+ typedef typename rebind_traits<_Alloc, Key>::const_reference
+ key_const_reference;
hash_eq_fn() { }
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
debug_map_base<Key, Eq_Fn, \
- typename _Alloc::template rebind<Key>::other::const_reference>
+ typename rebind_traits<_Alloc, Key>::const_reference>
#endif
entry_status m_stat;
};
- typedef typename _Alloc::template rebind<entry>::other entry_allocator;
- typedef typename entry_allocator::pointer entry_pointer;
- typedef typename entry_allocator::const_pointer const_entry_pointer;
- typedef typename entry_allocator::reference entry_reference;
- typedef typename entry_allocator::const_reference const_entry_reference;
- typedef typename entry_allocator::pointer entry_array;
+ typedef rebind_traits<_Alloc, entry> entry_traits;
+ typedef typename entry_traits::allocator_type entry_allocator;
+ typedef typename entry_traits::pointer entry_pointer;
+ typedef typename entry_traits::const_pointer const_entry_pointer;
+ typedef typename entry_traits::reference entry_reference;
+ typedef typename entry_traits::const_reference const_entry_reference;
+ typedef typename entry_traits::pointer entry_array;
typedef PB_DS_RANGED_PROBE_FN_C_DEC ranged_probe_fn_base;
#define PB_DS_RANGED_HASH_FN_HPP
#include <utility>
+#include <ext/pb_ds/detail/types_traits.hpp>
#include <debug/debug.h>
namespace __gnu_pbds
typedef typename _Alloc::size_type size_type;
typedef Hash_Fn hash_fn_base;
typedef Comb_Hash_Fn comb_hash_fn_base;
- typedef typename _Alloc::template rebind< Key>::other key_allocator;
- typedef typename key_allocator::const_reference key_const_reference;
+ typedef typename rebind_traits<_Alloc, Key>::const_reference
+ key_const_reference;
ranged_hash_fn(size_type);
typedef std::pair<size_type, size_type> comp_hash;
typedef Hash_Fn hash_fn_base;
typedef Comb_Hash_Fn comb_hash_fn_base;
- typedef typename _Alloc::template rebind<Key>::other key_allocator;
- typedef typename key_allocator::const_reference key_const_reference;
+ typedef typename rebind_traits<_Alloc, Key>::const_reference
+ key_const_reference;
ranged_hash_fn(size_type);
typedef Comb_Probe_Fn comb_probe_fn_base;
typedef Hash_Fn hash_fn_base;
typedef Probe_Fn probe_fn_base;
- typedef typename _Alloc::template rebind<Key>::other key_allocator;
- typedef typename key_allocator::const_reference key_const_reference;
+ typedef typename rebind_traits<_Alloc, Key>::const_reference
+ key_const_reference;
ranged_probe_fn(size_type);
typedef Comb_Probe_Fn comb_probe_fn_base;
typedef Hash_Fn hash_fn_base;
typedef Probe_Fn probe_fn_base;
- typedef typename _Alloc::template rebind<Key>::other key_allocator;
- typedef typename key_allocator::const_reference key_const_reference;
+ typedef typename rebind_traits<_Alloc, Key>::const_reference
+ key_const_reference;
ranged_probe_fn(size_type);
protected:
typedef typename _Alloc::size_type size_type;
typedef Comb_Probe_Fn comb_probe_fn_base;
- typedef typename _Alloc::template rebind<Key>::other key_allocator;
- typedef typename key_allocator::const_reference key_const_reference;
+ typedef typename rebind_traits<_Alloc, Key>::const_reference
+ key_const_reference;
ranged_probe_fn(size_type size)
{ Comb_Probe_Fn::notify_resized(size); }
#endif
class left_child_next_sibling_heap : public Cmp_Fn
{
- protected:
+ public:
typedef
- typename _Alloc::template rebind<
- left_child_next_sibling_heap_node_<Value_Type, Node_Metadata,
- _Alloc> >::other
- node_allocator;
-
- typedef typename node_allocator::value_type node;
- typedef typename node_allocator::pointer node_pointer;
- typedef typename node_allocator::const_pointer node_const_pointer;
+ left_child_next_sibling_heap_node_<Value_Type, Node_Metadata, _Alloc>
+ node;
+
+ private:
+ typedef typename detail::rebind_traits<_Alloc, node> alloc_traits;
+
+ protected:
+ typedef typename alloc_traits::allocator_type node_allocator;
+
+ typedef typename alloc_traits::pointer node_pointer;
+ typedef typename alloc_traits::const_pointer node_const_pointer;
typedef Node_Metadata node_metadata;
- typedef std::pair< node_pointer, node_pointer> node_pointer_pair;
+ typedef std::pair<node_pointer, node_pointer> node_pointer_pair;
private:
typedef cond_dealtor< node, _Alloc> cond_dealtor_t;
};
typedef integral_constant<int, simple_value> no_throw_copies_t;
- typedef typename _Alloc::template rebind<Value_Type> __rebind_v;
+ typedef rebind_traits<_Alloc, Value_Type> __rebind_v;
public:
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef Value_Type value_type;
- typedef typename __rebind_v::other::pointer pointer;
- typedef typename __rebind_v::other::const_pointer const_pointer;
- typedef typename __rebind_v::other::reference reference;
- typedef typename __rebind_v::other::const_reference const_reference;
+ typedef typename __rebind_v::pointer pointer;
+ typedef typename __rebind_v::const_pointer const_pointer;
+ typedef typename __rebind_v::reference reference;
+ typedef typename __rebind_v::const_reference const_reference;
typedef left_child_next_sibling_heap_node_point_const_iterator_<node, _Alloc>
point_const_iterator;
#ifndef PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_NODE_HPP
#define PB_DS_LEFT_CHILD_NEXT_SIBLING_HEAP_NODE_HPP
+#include <ext/pb_ds/detail/types_traits.hpp>
+
namespace __gnu_pbds
{
namespace detail
typedef typename _Alloc::size_type size_type;
typedef _Metadata metadata_type;
- typedef typename _Alloc::template rebind<this_type>::other::pointer node_pointer;
+ typedef typename rebind_traits<_Alloc, this_type>::pointer node_pointer;
value_type m_value;
metadata_type m_metadata;
typedef _Value value_type;
typedef typename _Alloc::size_type size_type;
- typedef typename _Alloc::template rebind<this_type>::other::pointer node_pointer;
+ typedef typename rebind_traits<_Alloc, this_type>::pointer node_pointer;
value_type m_value;
node_pointer m_p_l_child;
class left_child_next_sibling_heap_node_point_const_iterator_
{
protected:
- typedef typename _Alloc::template rebind<Node>::other::pointer node_pointer;
+ typedef typename rebind_traits<_Alloc, Node>::pointer node_pointer;
public:
/// Category.
typedef typename Node::value_type value_type;
/// Iterator's pointer type.
- typedef
- typename _Alloc::template rebind<
- value_type>::other::pointer
- pointer;
+ typedef typename rebind_traits<_Alloc, value_type>::pointer pointer;
/// Iterator's const pointer type.
- typedef
- typename _Alloc::template rebind<
- value_type>::other::const_pointer
- const_pointer;
+ typedef typename rebind_traits<_Alloc, value_type>::const_pointer
+ const_pointer;
/// Iterator's reference type.
- typedef
- typename _Alloc::template rebind<
- value_type>::other::reference
- reference;
+ typedef typename rebind_traits<_Alloc, value_type>::reference reference;
/// Iterator's const reference type.
- typedef
- typename _Alloc::template rebind<
- value_type>::other::const_reference
- const_reference;
+ typedef typename rebind_traits<_Alloc, value_type>::const_reference
+ const_reference;
inline
left_child_next_sibling_heap_node_point_const_iterator_(node_pointer p_nd) : m_p_nd(p_nd)
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
debug_map_base<Key, Eq_Fn, \
- typename _Alloc::template rebind<Key>::other::const_reference>
+ typename rebind_traits<_Alloc, Key>::const_reference>
#endif
/// list-based (with updates) associative container.
: public lu_map_entry_metadata_base<typename Update_Policy::metadata_type>
{
typename traits_base::value_type m_value;
- typename _Alloc::template rebind<entry>::other::pointer m_p_next;
+ typename rebind_traits<_Alloc, entry>::pointer m_p_next;
};
- typedef typename _Alloc::template rebind<entry>::other entry_allocator;
- typedef typename entry_allocator::pointer entry_pointer;
- typedef typename entry_allocator::const_pointer const_entry_pointer;
- typedef typename entry_allocator::reference entry_reference;
- typedef typename entry_allocator::const_reference const_entry_reference;
+ typedef rebind_traits<_Alloc, entry> entry_alloc_traits;
+ typedef typename entry_alloc_traits::allocator_type entry_allocator;
+ typedef typename entry_alloc_traits::pointer entry_pointer;
+ typedef typename entry_alloc_traits::const_pointer const_entry_pointer;
+ typedef typename entry_alloc_traits::reference entry_reference;
+ typedef typename entry_alloc_traits::const_reference const_entry_reference;
- typedef typename _Alloc::template rebind<entry_pointer>::other entry_pointer_allocator;
- typedef typename entry_pointer_allocator::pointer entry_pointer_array;
+ typedef rebind_traits<_Alloc, entry_pointer> entry_pointer_alloc_traits;
+ typedef typename entry_pointer_alloc_traits::allocator_type entry_pointer_allocator;
+ typedef typename entry_pointer_alloc_traits::pointer entry_pointer_array;
typedef typename traits_base::value_type value_type_;
typedef typename traits_base::pointer pointer_;
{
#ifdef PB_DS_DATA_TRUE_INDICATOR
typedef std::map<key_type, mapped_type, Cmp_Fn,
- typename _Alloc::template rebind<value_type>::other>
+ typename rebind_traits<_Alloc, value_type>::allocator_type>
map_type;
#else
typedef std::set<key_type, Cmp_Fn,
- typename _Alloc::template rebind<Key>::other>
+ typename rebind_traits<_Alloc, Key>::allocator_type>
map_type;
#endif
{
protected:
- typedef
- typename _Alloc::template rebind<
- Value_Type>::other::pointer
- pointer;
+ typedef typename rebind_traits<_Alloc, Value_Type>::pointer
+ pointer;
- typedef
- typename _Alloc::template rebind<
- Value_Type>::other::const_pointer
- const_pointer;
+ typedef typename rebind_traits<_Alloc, Value_Type>::const_pointer
+ const_pointer;
- typedef
- typename _Alloc::template rebind<
- Metadata_Type>::other::const_pointer
- const_metadata_pointer;
+ typedef typename rebind_traits<_Alloc, Metadata_Type>::const_pointer
+ const_metadata_pointer;
typedef PB_DS_OV_TREE_CONST_NODE_ITERATOR_C_DEC this_type;
typedef trivial_iterator_difference_type difference_type;
- typedef
- typename _Alloc::template rebind<
- Value_Type>::other::const_pointer
- value_type;
+ typedef typename rebind_traits<_Alloc, Value_Type>::const_pointer
+ value_type;
- typedef
- typename _Alloc::template rebind<
- typename remove_const<
- Value_Type>::type>::other::const_pointer
- reference;
+ typedef typename rebind_traits<_Alloc,
+ typename remove_const<Value_Type>::type>::const_pointer
+ reference;
- typedef
- typename _Alloc::template rebind<
- typename remove_const<
- Value_Type>::type>::other::const_pointer
- const_reference;
+ typedef typename rebind_traits<_Alloc,
+ typename remove_const<Value_Type>::type>::const_pointer
+ const_reference;
typedef Metadata_Type metadata_type;
- typedef
- typename _Alloc::template rebind<
- metadata_type>::other::const_reference
- metadata_const_reference;
+ typedef typename rebind_traits<_Alloc, metadata_type>::const_reference
+ metadata_const_reference;
public:
inline
- ov_tree_node_const_it_(const_pointer p_nd = 0, const_pointer p_begin_nd = 0, const_pointer p_end_nd = 0, const_metadata_pointer p_metadata = 0) : m_p_value(const_cast<pointer>(p_nd)), m_p_begin_value(const_cast<pointer>(p_begin_nd)), m_p_end_value(const_cast<pointer>(p_end_nd)), m_p_metadata(p_metadata)
+ ov_tree_node_const_it_(const_pointer p_nd = 0,
+ const_pointer p_begin_nd = 0,
+ const_pointer p_end_nd = 0,
+ const_metadata_pointer p_metadata = 0)
+ : m_p_value(const_cast<pointer>(p_nd)),
+ m_p_begin_value(const_cast<pointer>(p_begin_nd)),
+ m_p_end_value(const_cast<pointer>(p_end_nd)),
+ m_p_metadata(p_metadata)
{ }
inline const_reference
typedef trivial_iterator_difference_type difference_type;
- typedef
- typename _Alloc::template rebind<
- Value_Type>::other::pointer
- value_type;
+ typedef typename rebind_traits<_Alloc, Value_Type>::pointer
+ value_type;
- typedef
- typename _Alloc::template rebind<
- typename remove_const<
- Value_Type>::type>::other::pointer
- reference;
+ typedef typename rebind_traits<_Alloc,
+ typename remove_const<Value_Type>::type>::pointer
+ reference;
- typedef
- typename _Alloc::template rebind<
- typename remove_const<
- Value_Type>::type>::other::pointer
- const_reference;
+ typedef typename rebind_traits<_Alloc,
+ typename remove_const<Value_Type>::type>::pointer
+ const_reference;
inline
ov_tree_node_it_(const_pointer p_nd = 0, const_pointer p_begin_nd = 0, const_pointer p_end_nd = 0, const_metadata_pointer p_metadata = 0) : base_type(p_nd, p_begin_nd, p_end_nd, p_metadata)
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
debug_map_base<Key, eq_by_less<Key, Cmp_Fn>, \
- typename _Alloc::template rebind<Key>::other::const_reference>
+ typename rebind_traits<_Alloc, Key>::const_reference>
#endif
#ifdef PB_DS_TREE_TRACE
typedef typename remove_const<typename traits_base::value_type>::type non_const_value_type;
- typedef typename _Alloc::template rebind<non_const_value_type>::other value_allocator;
- typedef typename value_allocator::pointer value_vector;
+ typedef rebind_traits<_Alloc, non_const_value_type> value_alloc_traits;
+ typedef typename value_alloc_traits::allocator_type value_allocator;
+ typedef typename value_alloc_traits::pointer value_vector;
#ifdef _GLIBCXX_DEBUG
typedef PB_DS_DEBUG_MAP_BASE_C_DEC debug_base;
typedef typename traits_type::metadata_type metadata_type;
- typedef typename _Alloc::template rebind<metadata_type>::other metadata_allocator;
- typedef typename metadata_allocator::pointer metadata_pointer;
- typedef typename metadata_allocator::const_reference metadata_const_reference;
- typedef typename metadata_allocator::reference metadata_reference;
+ typedef rebind_traits<_Alloc, metadata_type> metadata_alloc_traits;
+ typedef typename metadata_alloc_traits::allocator_type metadata_allocator;
+ typedef typename metadata_alloc_traits::pointer metadata_pointer;
+ typedef typename metadata_alloc_traits::const_reference metadata_const_reference;
+ typedef typename metadata_alloc_traits::reference metadata_reference;
typedef typename traits_type::null_node_update_pointer
null_node_update_pointer;
public:
- typedef ov_tree_tag container_category;
+ typedef ov_tree_tag container_category;
typedef _Alloc allocator_type;
typedef typename _Alloc::size_type size_type;
typedef typename _Alloc::difference_type difference_type;
typedef PB_DS_P_HEAP_BASE base_type;
typedef typename base_type::node_pointer node_pointer;
- typedef typename _Alloc::template rebind<Value_Type>::other __rebind_a;
+ typedef rebind_traits<_Alloc, Value_Type> __rebind_a;
public:
typedef Value_Type value_type;
#ifdef _GLIBCXX_DEBUG
#define PB_DS_DEBUG_MAP_BASE_C_DEC \
debug_map_base<Key, eq_by_less<Key, std::less<Key> >, \
- typename _Alloc::template rebind<Key>::other::const_reference>
+ typename rebind_traits<_Alloc, Key>::const_reference>
#endif
{
private:
typedef pat_trie_base base_type;
- typedef PB_DS_PAT_TRIE_TRAITS_BASE traits_base;
+ typedef PB_DS_PAT_TRIE_TRAITS_BASE traits_base;
typedef Node_And_It_Traits traits_type;
typedef typename traits_type::synth_access_traits synth_access_traits;
typedef typename synth_access_traits::const_iterator a_const_iterator;
- typedef typename traits_type::node node;
- typedef typename _Alloc::template rebind<node> __rebind_n;
- typedef typename __rebind_n::other::const_pointer node_const_pointer;
- typedef typename __rebind_n::other::pointer node_pointer;
+ typedef typename traits_type::node node;
+ typedef rebind_traits<_Alloc, node> __rebind_n;
+ typedef typename __rebind_n::const_pointer node_const_pointer;
+ typedef typename __rebind_n::pointer node_pointer;
- typedef typename traits_type::head head;
- typedef typename _Alloc::template rebind<head> __rebind_h;
- typedef typename __rebind_h::other head_allocator;
- typedef typename head_allocator::pointer head_pointer;
+ typedef typename traits_type::head head;
+ typedef rebind_traits<_Alloc, head> __rebind_h;
+ typedef typename __rebind_h::allocator_type head_allocator;
+ typedef typename __rebind_h::pointer head_pointer;
- typedef typename traits_type::leaf leaf;
- typedef typename _Alloc::template rebind<leaf> __rebind_l;
- typedef typename __rebind_l::other leaf_allocator;
- typedef typename leaf_allocator::pointer leaf_pointer;
- typedef typename leaf_allocator::const_pointer leaf_const_pointer;
+ typedef typename traits_type::leaf leaf;
+ typedef rebind_traits<_Alloc, leaf> __rebind_l;
+ typedef typename __rebind_l::allocator_type leaf_allocator;
+ typedef typename __rebind_l::pointer leaf_pointer;
+ typedef typename __rebind_l::const_pointer leaf_const_pointer;
- typedef typename traits_type::inode inode;
+ typedef typename traits_type::inode inode;
typedef typename inode::iterator inode_iterator;
- typedef typename _Alloc::template rebind<inode> __rebind_in;
- typedef typename __rebind_in::other __rebind_ina;
- typedef typename __rebind_in::other inode_allocator;
- typedef typename __rebind_ina::pointer inode_pointer;
- typedef typename __rebind_ina::const_pointer inode_const_pointer;
+ typedef rebind_traits<_Alloc, inode> __rebind_in;
+ typedef typename __rebind_in::allocator_type inode_allocator;
+ typedef typename __rebind_in::pointer inode_pointer;
+ typedef typename __rebind_in::const_pointer inode_const_pointer;
/// Conditional deallocator.
{
private:
typedef inode_pointer __inp;
- typedef typename _Alloc::template rebind<__inp>::other __rebind_inp;
+ typedef typename rebind_traits<_Alloc, __inp>::allocator_type
+ __rebind_inp;
#ifdef _GLIBCXX_DEBUG
typedef std::_GLIBCXX_STD_C::list<__inp, __rebind_inp> bag_type;
{
typedef Metadata metadata_type;
typedef _Alloc allocator_type;
- typedef typename _Alloc::template rebind<Metadata> __rebind_m;
- typedef typename __rebind_m::other::const_reference const_reference;
+ typedef typename detail::rebind_traits<_Alloc, Metadata>::const_reference
+ const_reference;
const_reference
get_metadata() const
typedef _Alloc allocator_type;
typedef _ATraits access_traits;
typedef typename _ATraits::type_traits type_traits;
- typedef typename _Alloc::template rebind<_Node_base> __rebind_n;
- typedef typename __rebind_n::other::pointer node_pointer;
+ typedef typename detail::rebind_traits<_Alloc, _Node_base>::pointer
+ node_pointer;
node_pointer m_p_parent;
const node_type m_type;
_Node_base(node_type type) : m_type(type)
{ }
- typedef typename _Alloc::template rebind<_ATraits> __rebind_at;
- typedef typename __rebind_at::other::const_pointer a_const_pointer;
+ typedef typename detail::rebind_traits<_Alloc, _ATraits>::const_pointer
+ a_const_pointer;
typedef typename _ATraits::const_iterator a_const_iterator;
#ifdef _GLIBCXX_DEBUG
struct _Inode
: public _Node_base<_ATraits, Metadata>
{
- typedef _Node_base<_ATraits, Metadata> base_type;
- typedef typename base_type::type_traits type_traits;
- typedef typename base_type::access_traits access_traits;
- typedef typename type_traits::value_type value_type;
- typedef typename base_type::allocator_type _Alloc;
- typedef _Alloc allocator_type;
- typedef typename _Alloc::size_type size_type;
+ typedef _Node_base<_ATraits, Metadata> base_type;
+ typedef typename base_type::type_traits type_traits;
+ typedef typename base_type::access_traits access_traits;
+ typedef typename type_traits::value_type value_type;
+ typedef typename base_type::allocator_type _Alloc;
+ typedef _Alloc allocator_type;
+ typedef typename _Alloc::size_type size_type;
private:
- typedef typename base_type::a_const_pointer a_const_pointer;
- typedef typename base_type::a_const_iterator a_const_iterator;
+ typedef typename base_type::a_const_pointer a_const_pointer;
+ typedef typename base_type::a_const_iterator a_const_iterator;
- typedef typename base_type::node_pointer node_pointer;
- typedef typename _Alloc::template rebind<base_type> __rebind_n;
- typedef typename __rebind_n::other::const_pointer node_const_pointer;
+ typedef typename base_type::node_pointer node_pointer;
+ typedef typename detail::rebind_traits<_Alloc, base_type>::const_pointer
+ node_const_pointer;
- typedef _Leaf<_ATraits, Metadata> leaf;
- typedef typename _Alloc::template rebind<leaf>::other __rebind_l;
- typedef typename __rebind_l::pointer leaf_pointer;
- typedef typename __rebind_l::const_pointer leaf_const_pointer;
+ typedef _Leaf<_ATraits, Metadata> leaf;
+ typedef typename detail::rebind_traits<_Alloc, leaf> __rebind_l;
+ typedef typename __rebind_l::pointer leaf_pointer;
+ typedef typename __rebind_l::const_pointer leaf_const_pointer;
- typedef typename _Alloc::template rebind<_Inode>::other __rebind_in;
- typedef typename __rebind_in::pointer inode_pointer;
- typedef typename __rebind_in::const_pointer inode_const_pointer;
+ typedef detail::rebind_traits<_Alloc, _Inode> __rebind_in;
+ typedef typename __rebind_in::pointer inode_pointer;
+ typedef typename __rebind_in::const_pointer inode_const_pointer;
inline size_type
get_pref_pos(a_const_iterator, a_const_iterator, a_const_pointer) const;
public:
- typedef typename _Alloc::template rebind<node_pointer>::other __rebind_np;
+ typedef detail::rebind_traits<_Alloc, node_pointer> __rebind_np;
typedef typename __rebind_np::pointer node_pointer_pointer;
typedef typename __rebind_np::reference node_pointer_reference;
typedef typename type_traits::const_reference const_reference;
typedef allocator_type _Alloc;
- typedef typename _Alloc::template rebind<Node> __rebind_n;
- typedef typename __rebind_n::other::pointer node_pointer;
- typedef typename _Alloc::template rebind<Leaf> __rebind_l;
- typedef typename __rebind_l::other::pointer leaf_pointer;
- typedef typename __rebind_l::other::const_pointer leaf_const_pointer;
- typedef typename _Alloc::template rebind<Head> __rebind_h;
- typedef typename __rebind_h::other::pointer head_pointer;
-
- typedef typename _Alloc::template rebind<Inode> __rebind_in;
- typedef typename __rebind_in::other::pointer inode_pointer;
+ typedef typename rebind_traits<_Alloc, Node>::pointer node_pointer;
+ typedef typename rebind_traits<_Alloc, Leaf>::pointer leaf_pointer;
+ typedef typename rebind_traits<_Alloc, Leaf>::const_pointer leaf_const_pointer;
+ typedef typename rebind_traits<_Alloc, Head>::pointer head_pointer;
+
+ typedef typename rebind_traits<_Alloc, Inode>::pointer inode_pointer;
typedef typename Inode::iterator inode_iterator;
node_pointer m_p_nd;
class _Node_citer
{
protected:
- typedef typename _Alloc::template rebind<Node> __rebind_n;
- typedef typename __rebind_n::other::pointer node_pointer;
+ typedef typename rebind_traits<_Alloc, Node>::pointer node_pointer;
- typedef typename _Alloc::template rebind<Leaf> __rebind_l;
- typedef typename __rebind_l::other::pointer leaf_pointer;
- typedef typename __rebind_l::other::const_pointer leaf_const_pointer;
+ typedef typename rebind_traits<_Alloc, Leaf>::pointer leaf_pointer;
+ typedef typename rebind_traits<_Alloc, Leaf>::const_pointer leaf_const_pointer;
- typedef typename _Alloc::template rebind<Inode> __rebind_in;
- typedef typename __rebind_in::other::pointer inode_pointer;
- typedef typename __rebind_in::other::const_pointer inode_const_pointer;
+ typedef typename rebind_traits<_Alloc, Inode>::pointer inode_pointer;
+ typedef typename rebind_traits<_Alloc, Inode>::const_pointer inode_const_pointer;
typedef typename Node::a_const_pointer a_const_pointer;
typedef typename Node::a_const_iterator a_const_iterator;
typedef typename Node::metadata_type metadata_type;
/// Const metadata reference type.
- typedef typename _Alloc::template rebind<metadata_type> __rebind_m;
- typedef typename __rebind_m::other __rebind_ma;
- typedef typename __rebind_ma::const_reference metadata_const_reference;
+ typedef typename rebind_traits<_Alloc, metadata_type>::const_reference metadata_const_reference;
inline
_Node_citer(node_pointer p_nd = 0, a_const_pointer p_traits = 0)
private:
typedef _Node_citer<Node, Leaf, Head, Inode,
_CIterator, Iterator, _Alloc> base_type;
- typedef typename _Alloc::template rebind<Node> __rebind_n;
- typedef typename __rebind_n::other::pointer node_pointer;
+ typedef typename rebind_traits<_Alloc, Node>::pointer node_pointer;
typedef typename base_type::inode_pointer inode_pointer;
typedef typename base_type::a_const_pointer a_const_pointer;
typedef Iterator iterator;
typedef Value_Type value_type;
typedef Metadata metadata_type;
- typedef
- typename _Alloc::template rebind<
- rb_tree_node_<
- Value_Type,
- Metadata,
- _Alloc> >::other::pointer
- node_pointer;
-
- typedef
- typename _Alloc::template rebind<
- metadata_type>::other::reference
- metadata_reference;
-
- typedef
- typename _Alloc::template rebind<
- metadata_type>::other::const_reference
- metadata_const_reference;
+ typedef typename rebind_traits<_Alloc, rb_tree_node_>::pointer
+ node_pointer;
+
+ typedef typename rebind_traits<_Alloc, metadata_type>::reference
+ metadata_reference;
+
+ typedef typename rebind_traits<_Alloc, metadata_type>::const_reference
+ metadata_const_reference;
bool
special() const
typedef Value_Type value_type;
typedef null_type metadata_type;
- typedef
- typename _Alloc::template rebind<
- rb_tree_node_<
- Value_Type,
- null_type,
- _Alloc> >::other::pointer
- node_pointer;
+ typedef typename rebind_traits<_Alloc, rb_tree_node_>::pointer
+ node_pointer;
bool
special() const
typedef typename allocator_type::size_type size_type;
typedef _Node node;
- typedef typename _Alloc::template rebind<node> __rebind_n;
- typedef typename __rebind_n::other::pointer node_pointer;
+ typedef typename rebind_traits<_Alloc, node>::pointer node_pointer;
- typedef typename _Alloc::template rebind<node_pointer> __rebind_np;
- typedef typename __rebind_np::other::pointer entry_pointer;
- typedef typename __rebind_np::other::const_pointer entry_const_pointer;
+ typedef typename rebind_traits<_Alloc, node_pointer>::pointer
+ entry_pointer;
+ typedef typename rebind_traits<_Alloc, node_pointer>::const_pointer
+ entry_const_pointer;
enum
{
typedef Value_Type value_type;
typedef Metadata metadata_type;
- typedef
- typename _Alloc::template rebind<
- splay_tree_node_<Value_Type, Metadata, _Alloc> >::other::pointer
- node_pointer;
+ typedef typename rebind_traits<_Alloc, splay_tree_node_>::pointer
+ node_pointer;
- typedef
- typename _Alloc::template rebind<metadata_type>::other::reference
- metadata_reference;
+ typedef typename rebind_traits<_Alloc, metadata_type>::reference
+ metadata_reference;
- typedef
- typename _Alloc::template rebind<metadata_type>::other::const_reference
- metadata_const_reference;
+ typedef typename rebind_traits<_Alloc, metadata_type>::const_reference
+ metadata_const_reference;
#ifdef PB_DS_BIN_SEARCH_TREE_TRACE_
void
typedef Value_Type value_type;
typedef null_type metadata_type;
- typedef
- typename _Alloc::template rebind<
- splay_tree_node_<Value_Type, null_type, _Alloc> >::other::pointer
- node_pointer;
+ typedef typename rebind_traits<_Alloc, splay_tree_node_>::pointer
+ node_pointer;
inline bool
special() const
: public left_child_next_sibling_heap PB_DS_BASE_T_P
{
private:
- typedef typename _Alloc::template rebind<Value_Type>::other __rebind_a;
+ typedef rebind_traits<_Alloc, Value_Type> __rebind_a;
typedef left_child_next_sibling_heap PB_DS_BASE_T_P base_type;
protected:
typedef std::size_t size_type;
typedef std::string key_type;
- typedef typename _Alloc::template rebind<key_type> __rebind_k;
- typedef typename __rebind_k::other::const_reference key_const_reference;
+ typedef typename rebind_traits<_Alloc, key_type>::const_reference
+ key_const_reference;
typedef std::string::const_iterator const_iterator;
/// Element type.
/**
* @file detail/type_utils.hpp
- * Contains utilities for handnling types. All of these classes are based on
+ * Contains utilities for handling types. All of these classes are based on
* Modern C++ by Andrei Alxandrescu.
*/
#include <utility>
#include <ext/pb_ds/tag_and_trait.hpp>
#include <ext/pb_ds/detail/type_utils.hpp>
-#include <utility>
+#include <memory>
namespace __gnu_pbds
{
/// Primary template for representation of stored data.
/// Two types of data can be stored: value and hash.
- template<typename _Tv, typename _Th>
+ template<typename _Tv, typename _Th, bool Store_Hash>
struct stored_data
: public stored_value<_Tv>, public stored_hash<_Th>
{ };
/// Specialization for representation of stored data of just value type.
- template<typename _Tv>
- struct stored_data<_Tv, null_type>
+ template<typename _Tv, typename _Th>
+ struct stored_data<_Tv, _Th, false>
: public stored_value<_Tv>
{ };
- /// Primary template.
- template<typename Key, typename Mapped, typename _Alloc, bool Store_Hash>
- struct type_base;
-
- /**
- * Specialization of type_base for the case where the hash value
- * is not stored alongside each value.
- */
- template<typename Key, typename Mapped, typename _Alloc>
- struct type_base<Key, Mapped, _Alloc, false>
+ /// Choose value_type to be a key/value pair or just a key.
+ template<typename Key, typename Mapped>
+ struct select_value_type
{
- public:
- typedef typename _Alloc::size_type size_type;
-
- private:
- typedef typename _Alloc::template rebind<Mapped> __rebind_m;
- typedef typename __rebind_m::other __rebind_ma;
- typedef std::pair<const Key, Mapped> __value_type;
- typedef typename _Alloc::template rebind<__value_type> __rebind_v;
- typedef typename __rebind_v::other __rebind_va;
-
- public:
- typedef typename __rebind_ma::value_type mapped_type;
- typedef typename __rebind_ma::pointer mapped_pointer;
- typedef typename __rebind_ma::const_pointer mapped_const_pointer;
- typedef typename __rebind_ma::reference mapped_reference;
- typedef typename __rebind_ma::const_reference mapped_const_reference;
-
- typedef typename __rebind_va::value_type value_type;
- typedef typename __rebind_va::pointer pointer;
- typedef typename __rebind_va::const_pointer const_pointer;
- typedef typename __rebind_va::reference reference;
- typedef typename __rebind_va::const_reference const_reference;
-
- typedef stored_data<value_type, null_type> stored_data_type;
+ typedef std::pair<const Key, Mapped> type;
};
- /**
- * Specialization of type_base for the case where the hash value
- * is stored alongside each value.
- */
- template<typename Key, typename Mapped, typename _Alloc>
- struct type_base<Key, Mapped, _Alloc, true>
+ /// Specialization for sets where the key is the value_type.
+ template<typename Key>
+ struct select_value_type<Key, null_type>
{
- public:
- typedef typename _Alloc::size_type size_type;
-
- private:
- typedef typename _Alloc::template rebind<Mapped> __rebind_m;
- typedef typename __rebind_m::other __rebind_ma;
- typedef std::pair<const Key, Mapped> __value_type;
- typedef typename _Alloc::template rebind<__value_type> __rebind_v;
- typedef typename __rebind_v::other __rebind_va;
-
- public:
- typedef typename __rebind_ma::value_type mapped_type;
- typedef typename __rebind_ma::pointer mapped_pointer;
- typedef typename __rebind_ma::const_pointer mapped_const_pointer;
- typedef typename __rebind_ma::reference mapped_reference;
- typedef typename __rebind_ma::const_reference mapped_const_reference;
-
- typedef typename __rebind_va::value_type value_type;
- typedef typename __rebind_va::pointer pointer;
- typedef typename __rebind_va::const_pointer const_pointer;
- typedef typename __rebind_va::reference reference;
- typedef typename __rebind_va::const_reference const_reference;
-
- typedef stored_data<value_type, size_type> stored_data_type;
+ typedef Key type;
};
+ /// Base class for conditionally defining a static data member.
+ template<typename Key, typename Mapped, typename _Alloc, bool Store_Hash>
+ struct maybe_null_type
+ { };
- /**
- * Specialization of type_base for the case where the hash value
- * is not stored alongside each value.
- */
- template<typename Key, typename _Alloc>
- struct type_base<Key, null_type, _Alloc, false>
+ /// Specialization that defines a static data member of type null_type.
+ template<typename Key,typename _Alloc, bool Store_Hash>
+ struct maybe_null_type<Key, null_type, _Alloc, Store_Hash>
{
- public:
- typedef typename _Alloc::size_type size_type;
- typedef Key value_type;
-
- private:
- typedef typename _Alloc::template rebind<null_type> __rebind_m;
- typedef typename __rebind_m::other __rebind_ma;
- typedef typename _Alloc::template rebind<value_type> __rebind_v;
- typedef typename __rebind_v::other __rebind_va;
-
- public:
- typedef typename __rebind_ma::value_type mapped_type;
- typedef typename __rebind_ma::pointer mapped_pointer;
- typedef typename __rebind_ma::const_pointer mapped_const_pointer;
- typedef typename __rebind_ma::reference mapped_reference;
- typedef typename __rebind_ma::const_reference mapped_const_reference;
-
- typedef typename __rebind_va::pointer pointer;
- typedef typename __rebind_va::const_pointer const_pointer;
- typedef typename __rebind_va::reference reference;
- typedef typename __rebind_va::const_reference const_reference;
-
- typedef stored_data<value_type, null_type> stored_data_type;
-
- static null_type s_null_type;
+ static null_type s_null_type;
};
- template<typename Key, typename _Alloc>
+ template<typename Key,typename _Alloc, bool Store_Hash>
null_type
- type_base<Key, null_type, _Alloc, false>::s_null_type;
+ maybe_null_type<Key, null_type, _Alloc, Store_Hash>::s_null_type;
+ /// Consistent API for accessing allocator-related types.
+ template<typename _Alloc, typename T>
+ struct rebind_traits
+#if __cplusplus >= 201103L
+ : std::allocator_traits<_Alloc>::template rebind_traits<T>
+ {
+ using reference = T&;
+ using const_reference = const T&;
+ };
+#else
+ : _Alloc::template rebind<T>::other
+ {
+ typedef typename _Alloc::template rebind<T>::other allocator_type;
+ };
+#endif
- /**
- * Specialization of type_base for the case where the hash value
- * is stored alongside each value.
- */
- template<typename Key, typename _Alloc>
- struct type_base<Key, null_type, _Alloc, true>
+
+ /// Traits for abstract types.
+ template<typename Key, typename Mapped, typename _Alloc, bool Store_Hash>
+ struct types_traits
+ : public maybe_null_type<Key, Mapped, _Alloc, Store_Hash>
{
public:
- typedef typename _Alloc::size_type size_type;
- typedef Key value_type;
+ typedef typename _Alloc::size_type size_type;
+ typedef typename select_value_type<Key, Mapped>::type value_type;
+ typedef Key key_type;
+ typedef Mapped mapped_type;
private:
- typedef typename _Alloc::template rebind<null_type> __rebind_m;
- typedef typename __rebind_m::other __rebind_ma;
- typedef typename _Alloc::template rebind<value_type> __rebind_v;
- typedef typename __rebind_v::other __rebind_va;
+ typedef rebind_traits<_Alloc, value_type> __rebind_va;
+ typedef rebind_traits<_Alloc, key_type> __rebind_ka;
+ typedef rebind_traits<_Alloc, mapped_type> __rebind_ma;
+
+ typedef no_throw_copies<Key, Mapped> __nothrowcopy;
public:
- typedef typename __rebind_ma::value_type mapped_type;
typedef typename __rebind_ma::pointer mapped_pointer;
typedef typename __rebind_ma::const_pointer mapped_const_pointer;
typedef typename __rebind_ma::reference mapped_reference;
typedef typename __rebind_va::reference reference;
typedef typename __rebind_va::const_reference const_reference;
- typedef stored_data<value_type, size_type> stored_data_type;
+ typedef stored_data<value_type, size_type, Store_Hash> stored_data_type;
- static null_type s_null_type;
- };
-
- template<typename Key, typename _Alloc>
- null_type
- type_base<Key, null_type, _Alloc, true>::s_null_type;
-
-
- /// Type base dispatch.
- template<typename Key, typename Mapped, typename _Alloc, bool Store_Hash>
- struct type_dispatch
- {
- typedef type_base<Key, Mapped, _Alloc, Store_Hash> type;
- };
-
- /// Traits for abstract types.
- template<typename Key, typename Mapped, typename _Alloc, bool Store_Hash>
- struct types_traits
- : public type_dispatch<Key, Mapped, _Alloc, Store_Hash>::type
- {
- private:
- typedef no_throw_copies<Key, Mapped> __nothrowcopy;
- typedef typename _Alloc::template rebind<Key>::other __rebind_a;
-
- public:
- typedef typename _Alloc::size_type size_type;
- typedef typename __rebind_a::value_type key_type;
- typedef typename __rebind_a::pointer key_pointer;
- typedef typename __rebind_a::const_pointer key_const_pointer;
- typedef typename __rebind_a::reference key_reference;
- typedef typename __rebind_a::const_reference key_const_reference;
+ typedef typename __rebind_ka::pointer key_pointer;
+ typedef typename __rebind_ka::const_pointer key_const_pointer;
+ typedef typename __rebind_ka::reference key_reference;
+ typedef typename __rebind_ka::const_reference key_const_reference;
typedef std::pair<size_type, size_type> comp_hash;
typedef integral_constant<int, Store_Hash> store_extra;
typedef typename __nothrowcopy::indicator no_throw_indicator;
#include <bits/c++config.h>
#include <cstdlib>
+#include <ext/pb_ds/detail/types_traits.hpp>
#include <ext/pb_ds/detail/list_update_policy/lu_counter_metadata.hpp>
#include <ext/pb_ds/tag_and_trait.hpp>
/// Metadata on which this functor operates.
typedef null_type metadata_type;
- private:
- typedef typename _Alloc::template rebind<metadata_type> __rebind_m;
-
public:
/// Reference to metadata on which this functor operates.
- typedef typename __rebind_m::other::reference metadata_reference;
+ typedef typename detail::rebind_traits<_Alloc, metadata_type>::reference
+ metadata_reference;
/// Creates a metadata object.
metadata_type
private:
typedef detail::lu_counter_policy_base<size_type> base_type;
- typedef typename _Alloc::template rebind<metadata_type> __rebind_m;
public:
/// Reference to metadata on which this functor operates.
- typedef typename __rebind_m::other::reference metadata_reference;
+ typedef typename detail::rebind_traits<_Alloc, metadata_type>::reference
+ metadata_reference;
/// Creates a metadata object.
metadata_type
typedef typename detail::container_base_dispatch<_Tv, Cmp_Fn, _Alloc,
Tag>::type
base_type;
- typedef typename _Alloc::template rebind<_Tv> __rebind_v;
- typedef typename __rebind_v::other __rebind_va;
+ typedef detail::rebind_traits<_Alloc, _Tv> __rebind_va;
public:
typedef typename __rebind_va::reference reference;
/// Const pointer to the container's value-type.
typedef typename base_type::const_pointer const_pointer;
- typedef typename _Alloc::template rebind<metadata_type>::other __rebind_m;
-
/// Const metadata reference.
- typedef typename __rebind_m::const_reference metadata_const_reference;
+ typedef typename detail::rebind_traits<_Alloc, metadata_type>::const_reference
+ metadata_const_reference;
/// Metadata reference.
- typedef typename __rebind_m::reference metadata_reference;
+ typedef typename detail::rebind_traits<_Alloc, metadata_type>::reference
+ metadata_reference;
/// Returns the node_const_iterator associated with the tree's root node.
virtual node_const_iterator
public:
typedef typename _Alloc::size_type size_type;
typedef String key_type;
- typedef typename _Alloc::template rebind<key_type> __rebind_k;
- typedef typename __rebind_k::other::const_reference key_const_reference;
+ typedef typename detail::rebind_traits<_Alloc, key_type>::const_reference
+ key_const_reference;
enum
{