over_sequence.hpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. //-----------------------------------------------------------------------------
  2. // boost variant/detail/over_sequence.hpp header file
  3. // See http://www.boost.org for updates, documentation, and revision history.
  4. //-----------------------------------------------------------------------------
  5. //
  6. // Copyright (c) 2003
  7. // Eric Friedman
  8. //
  9. // Portions Copyright (C) 2002 David Abrahams
  10. //
  11. // Distributed under the Boost Software License, Version 1.0. (See
  12. // accompanying file LICENSE_1_0.txt or copy at
  13. // http://www.boost.org/LICENSE_1_0.txt)
  14. #ifndef BOOST_VARIANT_DETAIL_OVER_SEQUENCE_HPP
  15. #define BOOST_VARIANT_DETAIL_OVER_SEQUENCE_HPP
  16. #include "boost/mpl/aux_/config/ctps.hpp"
  17. #if defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  18. # include "boost/mpl/eval_if.hpp"
  19. # include "boost/mpl/bool.hpp"
  20. # include "boost/mpl/identity.hpp"
  21. # include "boost/type.hpp"
  22. #endif
  23. namespace boost {
  24. namespace detail { namespace variant {
  25. ///////////////////////////////////////////////////////////////////////////////
  26. // (detail) class over_sequence
  27. //
  28. // Wrapper used to indicate bounded types for variant are from type sequence.
  29. //
  30. template <typename Types>
  31. struct over_sequence
  32. {
  33. typedef Types type;
  34. };
  35. ///////////////////////////////////////////////////////////////////////////////
  36. // (detail) metafunction is_over_sequence (modeled on code by David Abrahams)
  37. //
  38. // Indicates whether the specified type is of form over_sequence<...> or not.
  39. //
  40. #if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  41. template <typename T>
  42. struct is_over_sequence
  43. : mpl::false_
  44. {
  45. };
  46. template <typename Types>
  47. struct is_over_sequence< over_sequence<Types> >
  48. : mpl::true_
  49. {
  50. };
  51. #else // defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
  52. typedef char (&yes_over_sequence_t)[1];
  53. typedef char (&no_over_sequence_t)[2];
  54. no_over_sequence_t is_over_sequence_test(...);
  55. template<typename T>
  56. yes_over_sequence_t is_over_sequence_test(
  57. type< ::boost::detail::variant::over_sequence<T> >
  58. );
  59. template<typename T>
  60. struct is_over_sequence_impl
  61. {
  62. BOOST_STATIC_CONSTANT(bool, value = (
  63. sizeof(is_over_sequence_test(type<T>()))
  64. == sizeof(yes_over_sequence_t)
  65. ));
  66. };
  67. template <typename T>
  68. struct is_over_sequence
  69. : mpl::bool_<
  70. ::boost::detail::variant::is_over_sequence_impl<T>::value
  71. >
  72. {
  73. };
  74. #endif // BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION workaround
  75. }} // namespace detail::variant
  76. } // namespace boost
  77. #endif // BOOST_VARIANT_DETAIL_OVER_SEQUENCE_HPP