//The following modifed from: /* From: "Robert Ramey" Newsgroups: gmane.comp.lib.boost.user Subject: challange to MPL gurus Date: Mon, 12 Dec 2011 11:41:09 -0800 */ #include #include #include #include #include #include #include #include #include #include #include namespace boost{namespace mpl{ template struct ForwardSequence { typedef typename end::type iter_end; //#define EMPTY_SEQ typedef #ifndef EMPTY_SEQ typename begin::type #else iter_end #endif iter_beg; BOOST_MPL_ASSERT (( is_convertible < typename iter_beg::category , forward_iterator_tag > )); template < typename StateIter > struct next_deref : next { typedef typename deref::type is_deref_able //check that StateIter is deref-able. ; //#define FAIL_ITER_CHECK #ifdef FAIL_ITER_CHECK private: struct my_private_t{}; BOOST_MPL_ASSERT (( is_same < is_deref_able , my_private_t > )) //Just to provide example test on //is_deref_able to test that //this template is instantiated. //This should always fail. ; #endif }; typedef typename if_recur < identity , not_ < boost::is_same < arg<1> , iter_end > > , next_deref > >::type type; }; void test_list_sequence(){ BOOST_CONCEPT_ASSERT(( ForwardSequence< list< int, char> > )); } }} int main() { boost::mpl::test_list_sequence(); return 0; }