//demo a simple recursive variant using fusion sequence container. // #include "boost/variant.hpp" #include "boost/blank.hpp" #include "boost/fusion/container/vector.hpp" #include "boost/fusion/include/at_c.hpp" #include #include template struct list_bounded ; template using list_var= boost::variant < boost::blank , boost::recursive_wrapper < list_bounded > > ; template struct list_bounded : boost::fusion::vector < T , list_var > { typedef boost::fusion::vector < T , list_var > super_t ; static constexpr char const* class_name="list_bounded" ; list_bounded ( T a_head , list_varconst& a_tail ) : super_t ( a_head , a_tail ) { std::cout<&& a_tail ) : super_t ( a_head , std::forward >(a_tail) ) { std::cout< { std::ostream& ost; list_printer(std::ostream& a_out):ost(a_out) {} void operator()(const boost::blank&) const { ost << "(blank) "; } template void operator()(const list_bounded& lst) const { ost << "( "; ost << boost::fusion::at_c<0>(lst) <<", "; boost::apply_visitor( *this, boost::fusion::at_c<1>(lst)); ost << ") "; } }; template< typename T> std::ostream& operator<< ( std::ostream& sout , list_varconst& a_list ) { list_printer prtr(sout); boost::apply_visitor( prtr, a_list); return sout; } int main() { typedef list_var list_int_t; list_int_t list_empty; std::cout << __LINE__<<":list_empty constructed which="<( 1, list_empty)); std::cout << __LINE__<<":list_empty copied which="<( 2, std::move(list_1))); std::cout << __LINE__<<":list_1 moved which="<