#include #include #include #include using namespace boost; using namespace boost::intrusive; template struct test { class item : public noncopyable , public Hook { public: item( int k ) :k(k) { } const int k; bool operator<( const item& other ) const { return k < other.k; } }; typedef boost::intrusive::set< item, Option > set; static void go() { set s; item i1(1); item i2(2); item i3(3); assert( s.insert(i1).second ); assert( s.insert(i2).second ); assert( s.insert(i3).second ); for ( auto& i : s ) std::cout << i.k << " "; std::cout << std::endl; s.clear(); } }; int main(int argc, char* argv[]) { typedef any_base_hook<> A; typedef set_base_hook<> S; typedef base_hook SO; typedef test< S, SO > without_any; typedef test< A, any_to_set_hook> > with_any; // working: prints 1 2 3 without_any::go(); // not working: prints 1 2 3 2 3 2 3 2 3... (infinite loop) with_any::go(); return 0; }