/Src/Dependencies/Boost/boost/variant/static_visitor.hpp

http://hadesmem.googlecode.com/ · C++ Header · 97 lines · 44 code · 24 blank · 29 comment · 0 complexity · 8bf2c15e1f71abb9df190ceacf0d3f99 MD5 · raw file

  1. //-----------------------------------------------------------------------------
  2. // boost variant/static_visitor.hpp header file
  3. // See http://www.boost.org for updates, documentation, and revision history.
  4. //-----------------------------------------------------------------------------
  5. //
  6. // Copyright (c) 2002-2003
  7. // Eric Friedman
  8. //
  9. // Distributed under the Boost Software License, Version 1.0. (See
  10. // accompanying file LICENSE_1_0.txt or copy at
  11. // http://www.boost.org/LICENSE_1_0.txt)
  12. #ifndef BOOST_VARIANT_STATIC_VISITOR_HPP
  13. #define BOOST_VARIANT_STATIC_VISITOR_HPP
  14. #include "boost/config.hpp"
  15. #include "boost/detail/workaround.hpp"
  16. #include "boost/mpl/if.hpp"
  17. #include "boost/type_traits/is_base_and_derived.hpp"
  18. #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
  19. # include "boost/type_traits/is_same.hpp"
  20. #endif
  21. // should be the last #include
  22. #include "boost/type_traits/detail/bool_trait_def.hpp"
  23. namespace boost {
  24. //////////////////////////////////////////////////////////////////////////
  25. // class template static_visitor
  26. //
  27. // An empty base class that typedefs the return type of a deriving static
  28. // visitor. The class is analogous to std::unary_function in this role.
  29. //
  30. namespace detail {
  31. struct is_static_visitor_tag { };
  32. typedef void static_visitor_default_return;
  33. } // namespace detail
  34. template <typename R = ::boost::detail::static_visitor_default_return>
  35. class static_visitor
  36. : public detail::is_static_visitor_tag
  37. {
  38. public: // typedefs
  39. typedef R result_type;
  40. protected: // for use as base class only
  41. static_visitor() { }
  42. ~static_visitor() { }
  43. };
  44. //////////////////////////////////////////////////////////////////////////
  45. // metafunction is_static_visitor
  46. //
  47. // Value metafunction indicates whether the specified type derives from
  48. // static_visitor<...>.
  49. //
  50. // NOTE #1: This metafunction does NOT check whether the specified type
  51. // fulfills the requirements of the StaticVisitor concept.
  52. //
  53. // NOTE #2: This template never needs to be specialized!
  54. //
  55. namespace detail {
  56. template <typename T>
  57. struct is_static_visitor_impl
  58. {
  59. BOOST_STATIC_CONSTANT(bool, value =
  60. (::boost::is_base_and_derived<
  61. detail::is_static_visitor_tag,
  62. T
  63. >::value));
  64. };
  65. } // namespace detail
  66. BOOST_TT_AUX_BOOL_TRAIT_DEF1(
  67. is_static_visitor
  68. , T
  69. , (::boost::detail::is_static_visitor_impl<T>::value)
  70. )
  71. } // namespace boost
  72. #include "boost/type_traits/detail/bool_trait_undef.hpp"
  73. #endif // BOOST_VARIANT_STATIC_VISITOR_HPP