Added missing non-const overloads to operator()

This commit is contained in:
Ion Gaztañaga
2014-11-09 14:14:24 +01:00
parent 2839598e85
commit 446f87f932
2 changed files with 21 additions and 3 deletions

View File

@@ -50,6 +50,13 @@ struct avltree_node_cloner
NodeTraits::set_balance(n, NodeTraits::get_balance(p)); NodeTraits::set_balance(n, NodeTraits::get_balance(p));
return n; return n;
} }
node_ptr operator()(const node_ptr & p) const
{
node_ptr n = base_t::get()(p);
NodeTraits::set_balance(n, NodeTraits::get_balance(p));
return n;
}
}; };
namespace detail { namespace detail {

View File

@@ -44,6 +44,7 @@ struct key_nodeptr_comp
static const bool value = is_same<T, const_node_ptr>::value || is_same<T, node_ptr>::value; static const bool value = is_same<T, const_node_ptr>::value || is_same<T, node_ptr>::value;
}; };
//key_forward
template<class T> template<class T>
const value_type & key_forward const value_type & key_forward
(const T &node, typename enable_if_c<is_node_ptr<T>::value>::type * = 0) const (const T &node, typename enable_if_c<is_node_ptr<T>::value>::type * = 0) const
@@ -53,13 +54,23 @@ struct key_nodeptr_comp
const T & key_forward(const T &key, typename enable_if_c<!is_node_ptr<T>::value>::type* = 0) const const T & key_forward(const T &key, typename enable_if_c<!is_node_ptr<T>::value>::type* = 0) const
{ return key; } { return key; }
//operator() 1 arg
template<class KeyType>
bool operator()(const KeyType &key1) const
{ return base_t::get()(this->key_forward(key1)); }
template<class KeyType>
bool operator()(const KeyType &key1)
{ return base_t::get()(this->key_forward(key1)); }
//operator() 2 arg
template<class KeyType, class KeyType2> template<class KeyType, class KeyType2>
bool operator()(const KeyType &key1, const KeyType2 &key2) const bool operator()(const KeyType &key1, const KeyType2 &key2) const
{ return base_t::get()(this->key_forward(key1), this->key_forward(key2)); } { return base_t::get()(this->key_forward(key1), this->key_forward(key2)); }
template<class KeyType> template<class KeyType, class KeyType2>
bool operator()(const KeyType &key1) const bool operator()(const KeyType &key1, const KeyType2 &key2)
{ return base_t::get()(this->key_forward(key1)); } { return base_t::get()(this->key_forward(key1), this->key_forward(key2)); }
const ValueTraits *const traits_; const ValueTraits *const traits_;
}; };