diff --git a/alib2std/src/extensions/container/tree.hpp b/alib2std/src/extensions/container/tree.hpp index a2533a96f0bf108143572e6ad62ad81fbe792687..cc0c03fbd77ba6851ca91e5a7991ad1271f5077b 100644 --- a/alib2std/src/extensions/container/tree.hpp +++ b/alib2std/src/extensions/container/tree.hpp @@ -34,6 +34,8 @@ #include <extensions/compare.hpp> #include <extensions/iterator.hpp> +#include "tuple.hpp" + namespace ext { /** @@ -1138,21 +1140,12 @@ public: * positive if this instance is bigger than \p other instance */ int compare ( const tree & other ) const { - static ext::compare < typename std::decay < T >::type > comp; - auto iterF = this->prefix_begin ( ); - auto iterS = other.prefix_begin ( ); - - for ( ; iterF != this->prefix_end ( ) || iterS != other.prefix_end ( ); ++iterF, ++iterS ) { - int res = comp ( * iterF, * iterS ); - - if ( res != 0 ) return res; - } - - if ( iterF != this->prefix_end ( ) ) return -1; + auto first = ext::tie ( this->getData ( ), this->getChildren ( ) ); + auto second = ext::tie ( other.getData ( ), other.getChildren ( ) ); - if ( iterS != other.prefix_end ( ) ) return 1; + static ext::compare < decltype ( first ) > comp; - return 0; + return comp ( first, second ); } /**