@@ -196,39 +196,39 @@ class AbstractRBTree {
196196 DEBUG_ONLY (mutable bool _expected_visited);
197197
198198private:
199- template <typename CMP>
200199 static constexpr bool HasKeyComparator =
201- std::is_invocable_r_v<RBTreeOrdering, decltype (&CMP ::cmp), K, K>;
200+ std::is_invocable_r_v<RBTreeOrdering, decltype (&COMPARATOR ::cmp), K, K>;
202201
203- template <typename CMP>
204202 static constexpr bool HasNodeComparator =
205- std::is_invocable_r_v<RBTreeOrdering, decltype (&CMP ::cmp), K, const NodeType*>;
203+ std::is_invocable_r_v<RBTreeOrdering, decltype (&COMPARATOR ::cmp), K, const NodeType*>;
206204
207205 template <typename CMP, typename = void >
208- static constexpr bool HasNodeVerifier = false ;
206+ static constexpr bool HasNodeVerifierImpl = false ;
209207
210208 template <typename CMP>
211- static constexpr bool HasNodeVerifier <CMP, std::void_t <decltype (&CMP::less_than)>> =
209+ static constexpr bool HasNodeVerifierImpl <CMP, std::void_t <decltype (&CMP::less_than)>> =
212210 std::is_invocable_r_v<bool , decltype (&CMP::less_than), const NodeType*, const NodeType*>;
213211
212+ static constexpr bool HasNodeVerifier = HasNodeVerifierImpl<COMPARATOR>;
213+
214214 RBTreeOrdering cmp (const K& a, const NodeType* b) const {
215- if constexpr (HasNodeComparator<COMPARATOR> ) {
215+ if constexpr (HasNodeComparator) {
216216 return COMPARATOR::cmp (a, b);
217- } else if constexpr (HasKeyComparator<COMPARATOR> ) {
217+ } else if constexpr (HasKeyComparator) {
218218 return COMPARATOR::cmp (a, b->key ());
219219 }
220220 }
221221
222222 bool less_than (const NodeType* a, const NodeType* b) const {
223- if constexpr (HasNodeVerifier<COMPARATOR> ) {
223+ if constexpr (HasNodeVerifier) {
224224 return COMPARATOR::less_than (a, b);
225225 } else {
226226 return true ;
227227 }
228228 }
229229
230230 void assert_key_leq (K a, K b) const {
231- if constexpr (HasKeyComparator<COMPARATOR> ) { // Cannot assert if no key comparator exist.
231+ if constexpr (HasKeyComparator) { // Cannot assert if no key comparator exist.
232232 assert (COMPARATOR::cmp (a, b) != RBTreeOrdering::GT, " key a must be less or equal to key b" );
233233 }
234234 }
@@ -272,8 +272,7 @@ class AbstractRBTree {
272272
273273 AbstractRBTree () : _num_nodes(0 ), _root(nullptr ) DEBUG_ONLY(COMMA _expected_visited (false )) {
274274 static_assert (std::is_trivially_destructible<K>::value, " key type must be trivially destructable" );
275- static_assert (HasKeyComparator<COMPARATOR> || HasNodeComparator<COMPARATOR>,
276- " comparator must be of correct type" );
275+ static_assert (HasKeyComparator || HasNodeComparator, " comparator must be of correct type" );
277276 }
278277
279278 size_t size () const { return _num_nodes; }
@@ -433,9 +432,9 @@ class AbstractRBTree {
433432 // If provided, each node is also verified through this callable.
434433 template <typename USER_VERIFIER = empty_verifier>
435434 void verify_self (const USER_VERIFIER& extra_verifier = USER_VERIFIER()) const {
436- if constexpr (HasNodeVerifier<COMPARATOR> ) {
435+ if constexpr (HasNodeVerifier) {
437436 verify_self ([](const NodeType* a, const NodeType* b){ return COMPARATOR::less_than (a, b);}, extra_verifier);
438- } else if constexpr (HasKeyComparator<COMPARATOR> ) {
437+ } else if constexpr (HasKeyComparator) {
439438 verify_self ([](const NodeType* a, const NodeType* b){ return COMPARATOR::cmp (a->key (), b->key ()) == RBTreeOrdering::LT; }, extra_verifier);
440439 } else {
441440 verify_self ([](const NodeType*, const NodeType*){ return true ;}, extra_verifier);
0 commit comments