function_arity.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031
  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/function_types/function_arity.hpp>
  8. class C;
  9. typedef C func();
  10. typedef C (*func_ptr)(int);
  11. typedef C (&func_ref)(int,int);
  12. typedef C (C::*mem_func_ptr)();
  13. typedef C (C::*c_mem_func_ptr)(int) const;
  14. typedef C (C::*v_mem_func_ptr)(int,int) volatile;
  15. typedef C (C::*cv_mem_func_ptr)(int,int,int) const volatile;
  16. typedef int C::* mem_ptr;
  17. BOOST_MPL_ASSERT_RELATION( ::boost::function_types::function_arity<func>::value, ==, 0 );
  18. BOOST_MPL_ASSERT_RELATION( ::boost::function_types::function_arity<func_ptr>::value, ==, 1 );
  19. BOOST_MPL_ASSERT_RELATION( ::boost::function_types::function_arity<func_ref>::value, ==, 2 );
  20. BOOST_MPL_ASSERT_RELATION( ::boost::function_types::function_arity<mem_func_ptr>::value, ==, 1 );
  21. BOOST_MPL_ASSERT_RELATION( ::boost::function_types::function_arity<c_mem_func_ptr>::value, ==, 2 );
  22. BOOST_MPL_ASSERT_RELATION( ::boost::function_types::function_arity<v_mem_func_ptr>::value, ==, 3 );
  23. BOOST_MPL_ASSERT_RELATION( ::boost::function_types::function_arity<cv_mem_func_ptr>::value, ==, 4 );
  24. BOOST_MPL_ASSERT_RELATION( ::boost::function_types::function_arity<mem_ptr>::value, ==, 1 );