components_seq.cpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // (C) Copyright Tobias Schwinger
  2. //
  3. // Use modification and distribution are subject to the boost Software License,
  4. // Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt).
  5. //------------------------------------------------------------------------------
  6. #include <boost/type_traits/is_same.hpp>
  7. #include <boost/mpl/assert.hpp>
  8. #include <boost/mpl/vector.hpp>
  9. #include <boost/mpl/equal.hpp>
  10. #include <boost/mpl/front.hpp>
  11. #include <boost/mpl/back.hpp>
  12. #include <boost/mpl/at.hpp>
  13. #include <boost/mpl/begin_end.hpp>
  14. #include <boost/mpl/clear.hpp>
  15. #include <boost/mpl/push_front.hpp>
  16. #include <boost/mpl/pop_front.hpp>
  17. #include <boost/mpl/push_back.hpp>
  18. #include <boost/mpl/pop_back.hpp>
  19. #include <boost/mpl/size.hpp>
  20. #include <boost/mpl/empty.hpp>
  21. #include <boost/function_types/components.hpp>
  22. namespace ft = boost::function_types;
  23. namespace mpl = boost::mpl;
  24. using boost::is_same;
  25. class C;
  26. typedef C (C::* mem_func_ptr)(int);
  27. typedef ft::components<mem_func_ptr> c;
  28. // front
  29. BOOST_MPL_ASSERT(( is_same< ::boost::mpl::front<c>::type, C > ));
  30. // back
  31. BOOST_MPL_ASSERT(( is_same< ::boost::mpl::back<c>::type, int > ));
  32. // at
  33. BOOST_MPL_ASSERT(( is_same< ::boost::mpl::at_c<c,0>::type, C > ));
  34. BOOST_MPL_ASSERT(( is_same< ::boost::mpl::at_c<c,1>::type, C & > ));
  35. BOOST_MPL_ASSERT(( is_same< ::boost::mpl::at_c<c,2>::type, int > ));
  36. // begin/end
  37. BOOST_MPL_ASSERT(( mpl::equal< c, mpl::vector<C,C &, int> > ));
  38. // clear
  39. BOOST_MPL_ASSERT(( mpl::equal< mpl::clear<c>, mpl::vector<> > ));
  40. // push_front
  41. BOOST_MPL_ASSERT(( mpl::equal< mpl::push_front<c,C>::type, mpl::vector<C,C,C &,int> > ));
  42. // pop_front
  43. BOOST_MPL_ASSERT(( mpl::equal< mpl::pop_front<c>::type, mpl::vector<C &,int> > ));
  44. // push_back
  45. BOOST_MPL_ASSERT(( mpl::equal< mpl::push_back<c,C>::type, mpl::vector<C,C &,int,C> > ));
  46. // pop_back
  47. BOOST_MPL_ASSERT(( mpl::equal< mpl::pop_back<c>::type, mpl::vector<C,C &> > ));
  48. // size
  49. BOOST_MPL_ASSERT_RELATION( ::boost::mpl::size<c>::value, ==, 3 );
  50. // empty
  51. BOOST_MPL_ASSERT_NOT(( mpl::empty<c> ));
  52. BOOST_MPL_ASSERT(( mpl::empty< mpl::clear<c> > ));