On 12/12/11 16:39, Jeremiah Willcock wrote: [snip]
Here's my version:
template<typename I> struct ForwardIterator;
template
struct check_unless_end {}; template <typename I> struct check_unless_end { typedef typename boost::mpl::deref<I>::type t1; typedef typename boost::mpl::next<I>::type t2; BOOST_CONCEPT_ASSERT(( ForwardIterator<t2> )); };
template<typename I> struct ForwardIterator { typedef typename boost::mpl::print< I >::type t1; typedef check_unless_end< I, boost::is_same< boost::mpl::l_iterboost::mpl::l_end, I > > t2; BOOST_MPL_ASSERT(( boost::is_convertible< typename I::category, boost::mpl::forward_iterator_tag > )); };
template<typename S> struct ForwardSequence { typedef typename boost::mpl::end<S>::type t2; BOOST_CONCEPT_ASSERT(( ForwardIterator<t2> )); };
#include
void test_list_sequence(){ BOOST_CONCEPT_ASSERT(( ForwardSequence< boost::mpl::list > )); } -- Jeremiah Willcock Hi Jeremiah,
After adding the #include's shown in the attached, I got warning: k/boost/mpl/print.hpp:55:10: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] Simply rm'ing the print typedef solved the problem and seems harmless since the t1 is not used anywhere. Looking at your code, it seems you solved the problem by removing the nested specialization of is_end, with a specialization in file scope of check_unless_end. I've a vague memory of hearing some similar solution elsewhere. Is there some reason why specializations cannot occur within the class? -regards, Larry