type_traits.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // type_traits.hpp
  3. //
  4. // Copyright 2008 Eric Niebler. Distributed under the Boost
  5. // Software License, Version 1.0. (See accompanying file
  6. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. #ifndef BOOST_XPRESSIVE_DETAIL_STATIC_TYPE_TRAITS_HPP_EAN_10_04_2005
  8. #define BOOST_XPRESSIVE_DETAIL_STATIC_TYPE_TRAITS_HPP_EAN_10_04_2005
  9. // MS compatible compilers support #pragma once
  10. #if defined(_MSC_VER)
  11. # pragma once
  12. #endif
  13. #include <string>
  14. #include <boost/config.hpp>
  15. #include <boost/mpl/bool.hpp>
  16. #include <boost/iterator/iterator_traits.hpp>
  17. #include <boost/type_traits/is_convertible.hpp>
  18. #include <boost/xpressive/detail/detail_fwd.hpp>
  19. namespace boost { namespace xpressive { namespace detail
  20. {
  21. ///////////////////////////////////////////////////////////////////////////////
  22. // is_static_xpression
  23. //
  24. template<typename T>
  25. struct is_static_xpression
  26. : mpl::false_
  27. {
  28. };
  29. template<typename Matcher, typename Next>
  30. struct is_static_xpression<static_xpression<Matcher, Next> >
  31. : mpl::true_
  32. {
  33. };
  34. template<typename Top, typename Next>
  35. struct is_static_xpression<stacked_xpression<Top, Next> >
  36. : mpl::true_
  37. {
  38. };
  39. //////////////////////////////////////////////////////////////////////////
  40. // is_random
  41. //
  42. template<typename BidiIter>
  43. struct is_random
  44. : is_convertible
  45. <
  46. typename iterator_category<BidiIter>::type
  47. , std::random_access_iterator_tag
  48. >
  49. {
  50. };
  51. //////////////////////////////////////////////////////////////////////////
  52. // is_string_iterator
  53. //
  54. template<typename Iter>
  55. struct is_string_iterator
  56. : mpl::false_
  57. {
  58. };
  59. template<>
  60. struct is_string_iterator<std::string::iterator>
  61. : mpl::true_
  62. {
  63. };
  64. template<>
  65. struct is_string_iterator<std::string::const_iterator>
  66. : mpl::true_
  67. {
  68. };
  69. #ifndef BOOST_NO_STD_WSTRING
  70. template<>
  71. struct is_string_iterator<std::wstring::iterator>
  72. : mpl::true_
  73. {
  74. };
  75. template<>
  76. struct is_string_iterator<std::wstring::const_iterator>
  77. : mpl::true_
  78. {
  79. };
  80. #endif
  81. ///////////////////////////////////////////////////////////////////////////////
  82. // is_char
  83. //
  84. template<typename T>
  85. struct is_char
  86. : mpl::false_
  87. {};
  88. template<>
  89. struct is_char<char>
  90. : mpl::true_
  91. {};
  92. template<>
  93. struct is_char<wchar_t>
  94. : mpl::true_
  95. {};
  96. }}} // namespace boost::xpressive::detail
  97. #endif