args.hpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. ///////////////////////////////////////////////////////////////////////////////
  2. /// \file args.hpp
  3. /// Contains definition of \c term\<\>, \c list1\<\>, \c list2\<\>, ...
  4. /// class templates.
  5. //
  6. // Copyright 2008 Eric Niebler. Distributed under the Boost
  7. // Software License, Version 1.0. (See accompanying file
  8. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  9. #ifndef BOOST_PROTO_ARGS_HPP_EAN_04_01_2005
  10. #define BOOST_PROTO_ARGS_HPP_EAN_04_01_2005
  11. #include <boost/preprocessor/cat.hpp>
  12. #include <boost/preprocessor/arithmetic/dec.hpp>
  13. #include <boost/preprocessor/iteration/iterate.hpp>
  14. #include <boost/preprocessor/repetition/enum_params.hpp>
  15. #include <boost/preprocessor/repetition/repeat.hpp>
  16. #include <boost/preprocessor/repetition/repeat_from_to.hpp>
  17. #include <boost/mpl/if.hpp>
  18. #include <boost/mpl/void.hpp>
  19. #include <boost/proto/proto_fwd.hpp>
  20. #include <boost/proto/detail/is_noncopyable.hpp>
  21. #include <boost/mpl/or.hpp>
  22. #include <boost/type_traits/is_function.hpp>
  23. #include <boost/type_traits/is_abstract.hpp>
  24. namespace boost { namespace proto
  25. {
  26. namespace detail
  27. {
  28. /// INTERNAL ONLY
  29. template<typename Expr>
  30. struct expr_traits
  31. {
  32. typedef Expr value_type;
  33. typedef Expr &reference;
  34. typedef Expr const &const_reference;
  35. };
  36. /// INTERNAL ONLY
  37. template<typename Expr>
  38. struct expr_traits<Expr &>
  39. {
  40. typedef Expr value_type;
  41. typedef Expr &reference;
  42. typedef Expr &const_reference;
  43. };
  44. /// INTERNAL ONLY
  45. template<typename Expr>
  46. struct expr_traits<Expr const &>
  47. {
  48. typedef Expr value_type;
  49. typedef Expr const &reference;
  50. typedef Expr const &const_reference;
  51. };
  52. /// INTERNAL ONLY
  53. template<typename T>
  54. struct term_traits
  55. {
  56. typedef T value_type;
  57. typedef T &reference;
  58. typedef T const &const_reference;
  59. };
  60. /// INTERNAL ONLY
  61. template<typename T>
  62. struct term_traits<T &>
  63. {
  64. typedef typename mpl::if_c<is_noncopyable<T>::value, T &, T>::type value_type;
  65. typedef T &reference;
  66. typedef T &const_reference;
  67. };
  68. /// INTERNAL ONLY
  69. template<typename T>
  70. struct term_traits<T const &>
  71. {
  72. typedef T value_type;
  73. typedef T const &reference;
  74. typedef T const &const_reference;
  75. };
  76. /// INTERNAL ONLY
  77. template<typename T, std::size_t N>
  78. struct term_traits<T (&)[N]>
  79. {
  80. typedef T value_type[N];
  81. typedef T (&reference)[N];
  82. typedef T (&const_reference)[N];
  83. };
  84. /// INTERNAL ONLY
  85. template<typename T, std::size_t N>
  86. struct term_traits<T const (&)[N]>
  87. {
  88. typedef T value_type[N];
  89. typedef T const (&reference)[N];
  90. typedef T const (&const_reference)[N];
  91. };
  92. /// INTERNAL ONLY
  93. template<typename T, std::size_t N>
  94. struct term_traits<T[N]>
  95. {
  96. typedef T value_type[N];
  97. typedef T (&reference)[N];
  98. typedef T const (&const_reference)[N];
  99. };
  100. /// INTERNAL ONLY
  101. template<typename T, std::size_t N>
  102. struct term_traits<T const[N]>
  103. {
  104. typedef T value_type[N];
  105. typedef T const (&reference)[N];
  106. typedef T const (&const_reference)[N];
  107. };
  108. }
  109. namespace argsns_
  110. {
  111. // This is where term and all the different listN templates are defined
  112. #include <boost/proto/detail/args.hpp>
  113. }
  114. }}
  115. #endif