
"Andy Little" <andy@servocomm.freeserve.co.uk> wrote in message news:ea4hqs$lg0$1@sea.gmane.org... Further the following code should work AFAICS, at least according to the documentation #include <boost/mpl/equal_to.hpp> #include <boost/mpl/integral_c.hpp> #include <boost/mpl/next.hpp> #include <boost/mpl/prior.hpp> #include <boost/mpl/assert.hpp> #include <boost/type_traits/is_same.hpp> #include <boost/static_assert.hpp> #include <boost/mpl/bool.hpp> #include <boost/mpl/int.hpp> #include <boost/mpl/integral_c.hpp> #include <iostream> // Write a type fulfilling the Integral Constant requirements // http://www.boost.org/libs/mpl/doc/refmanual/integral-constant.html template <int N> struct my_int{ typedef int value_type; static const int value = N; operator int ()const { return value;} typedef my_int type; }; namespace boost{ namespace mpl{ template <int N > struct next<my_int<N> > { typedef my_int<N+1> type; }; template <int N > struct prior<my_int<N> > { typedef my_int<N-1> type; }; }} /* Check a type is a model of Integral Constant http://www.boost.org/libs/mpl/doc/refmanual/integral-constant.html */ template <typename T> void IntegralConstantConcept() { typedef typename boost::mpl::next<T>::type next_type; typedef typename boost::mpl::prior<T>::type prior_type; typedef typename T::type type; typedef typename T::value_type value_type; typename T::value_type t = T::value; typename T::value_type t1 = T(); static int const next_value = T::value +1; static int const prior_value = T::value -1; BOOST_MPL_ASSERT( (boost::is_same<type,T>) ); BOOST_STATIC_ASSERT( (next_type::value == next_value)); BOOST_STATIC_ASSERT( (prior_type::value == prior_value)); std::cout << typeid (T).name() << "passed Integral Concept Concept Check\n"; }; namespace mpl = boost::mpl; int main() { // Concept check IntegralConstantConcept<my_int<1> >(); IntegralConstantConcept<mpl::integral_c<int,1> >(); IntegralConstantConcept<mpl::int_<1> >(); // fails // IntegralConstantConcept<mpl::bool_<true> >(); // should fail // IntegralConstantConcept<int >(); // Should work ! // http://www.boost.org/libs/mpl/doc/refmanual/equal-to.html bool result = mpl::equal_to< my_int<1>,my_int<1> >::value ; std::cout << result << '\n'; } regards Andy Little