components.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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/mpl/assert.hpp>
  7. #include <boost/mpl/vector.hpp>
  8. #include <boost/mpl/equal.hpp>
  9. #include <boost/function_types/components.hpp>
  10. namespace ft = boost::function_types;
  11. namespace mpl = boost::mpl;
  12. class C;
  13. typedef C func();
  14. typedef C (*func_ptr)(int);
  15. typedef C (&func_ref)(int,int);
  16. typedef C (C::*mem_func_ptr)();
  17. typedef C (C::*c_mem_func_ptr)(int) const;
  18. typedef C (C::*v_mem_func_ptr)(int,int) volatile;
  19. typedef C (C::*cv_mem_func_ptr)(int,int,int) const volatile;
  20. typedef int C::* mem_ptr;
  21. BOOST_MPL_ASSERT((
  22. mpl::equal< ft::components<func>::types, mpl::vector<C> >
  23. ));
  24. BOOST_MPL_ASSERT((
  25. mpl::equal< ft::components<func_ptr>::types, mpl::vector<C,int> >
  26. ));
  27. BOOST_MPL_ASSERT((
  28. mpl::equal< ft::components<func_ref>::types, mpl::vector<C,int,int> >
  29. ));
  30. BOOST_MPL_ASSERT((
  31. mpl::equal< ft::components<mem_func_ptr>::types, mpl::vector<C,C &> >
  32. ));
  33. BOOST_MPL_ASSERT((
  34. mpl::equal< ft::components<c_mem_func_ptr>::types, mpl::vector<C,C const &,int> >
  35. ));
  36. BOOST_MPL_ASSERT((
  37. mpl::equal< ft::components<v_mem_func_ptr>::types, mpl::vector<C,C volatile &,int,int> >
  38. ));
  39. BOOST_MPL_ASSERT((
  40. mpl::equal< ft::components<cv_mem_func_ptr>::types, mpl::vector<C,C const volatile &,int,int,int> >
  41. ));
  42. BOOST_MPL_ASSERT((
  43. mpl::equal< ft::components<mem_ptr>::types, mpl::vector<int &,C&> >
  44. ));