template_arity.hpp 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Copyright Aleksey Gurtovoy 2001-2004
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // *Preprocessed* version of the main "template_arity.hpp" header
  8. // -- DO NOT modify by hand!
  9. namespace boost { namespace mpl { namespace aux {
  10. template< int N > struct arity_tag
  11. {
  12. typedef char (&type)[N + 1];
  13. };
  14. template<
  15. int C1, int C2, int C3, int C4, int C5, int C6
  16. >
  17. struct max_arity
  18. {
  19. BOOST_STATIC_CONSTANT(int, value =
  20. ( C6 > 0 ? C6 : ( C5 > 0 ? C5 : ( C4 > 0 ? C4 : ( C3 > 0 ? C3 : ( C2 > 0 ? C2 : ( C1 > 0 ? C1 : -1 ) ) ) ) ) )
  21. );
  22. };
  23. arity_tag<0>::type arity_helper(...);
  24. template<
  25. template< typename P1 > class F
  26. , typename T1
  27. >
  28. typename arity_tag<1>::type
  29. arity_helper(type_wrapper< F<T1> >, arity_tag<1>);
  30. template<
  31. template< typename P1, typename P2 > class F
  32. , typename T1, typename T2
  33. >
  34. typename arity_tag<2>::type
  35. arity_helper(type_wrapper< F< T1,T2 > >, arity_tag<2>);
  36. template<
  37. template< typename P1, typename P2, typename P3 > class F
  38. , typename T1, typename T2, typename T3
  39. >
  40. typename arity_tag<3>::type
  41. arity_helper(type_wrapper< F< T1,T2,T3 > >, arity_tag<3>);
  42. template<
  43. template< typename P1, typename P2, typename P3, typename P4 > class F
  44. , typename T1, typename T2, typename T3, typename T4
  45. >
  46. typename arity_tag<4>::type
  47. arity_helper(type_wrapper< F< T1,T2,T3,T4 > >, arity_tag<4>);
  48. template<
  49. template<
  50. typename P1, typename P2, typename P3, typename P4
  51. , typename P5
  52. >
  53. class F
  54. , typename T1, typename T2, typename T3, typename T4, typename T5
  55. >
  56. typename arity_tag<5>::type
  57. arity_helper(type_wrapper< F< T1,T2,T3,T4,T5 > >, arity_tag<5>);
  58. template<
  59. template<
  60. typename P1, typename P2, typename P3, typename P4
  61. , typename P5, typename P6
  62. >
  63. class F
  64. , typename T1, typename T2, typename T3, typename T4, typename T5
  65. , typename T6
  66. >
  67. typename arity_tag<6>::type
  68. arity_helper(type_wrapper< F< T1,T2,T3,T4,T5,T6 > >, arity_tag<6>);
  69. template< typename F, int N >
  70. struct template_arity_impl
  71. {
  72. BOOST_STATIC_CONSTANT(int, value =
  73. sizeof(::boost::mpl::aux::arity_helper(type_wrapper<F>(), arity_tag<N>())) - 1
  74. );
  75. };
  76. template< typename F >
  77. struct template_arity
  78. {
  79. BOOST_STATIC_CONSTANT(int, value = (
  80. max_arity< template_arity_impl< F,1 >::value, template_arity_impl< F,2 >::value, template_arity_impl< F,3 >::value, template_arity_impl< F,4 >::value, template_arity_impl< F,5 >::value, template_arity_impl< F,6 >::value >::value
  81. ));
  82. typedef mpl::int_<value> type;
  83. };
  84. }}}