is_variant.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*=============================================================================
  2. Copyright (c) 2001-2014 Joel de Guzman
  3. http://spirit.sourceforge.net/
  4. Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. =============================================================================*/
  7. #if !defined(BOOST_SPIRIT_X3_IS_VARIANT_JAN_10_2012_0823AM)
  8. #define BOOST_SPIRIT_X3_IS_VARIANT_JAN_10_2012_0823AM
  9. #include <boost/variant.hpp>
  10. #include <boost/mpl/has_xxx.hpp>
  11. #include <boost/mpl/bool.hpp>
  12. namespace boost { namespace spirit { namespace x3 { namespace traits
  13. {
  14. namespace detail
  15. {
  16. // By declaring a nested struct in your class/struct, you tell
  17. // spirit that it is regarded as a variant type. The minimum
  18. // required interface for such a variant is that it has constructors
  19. // for various types supported by your variant and a typedef 'types'
  20. // which is an mpl sequence of the contained types.
  21. //
  22. // This is an intrusive interface. For a non-intrusive interface,
  23. // use the is_variant trait.
  24. BOOST_MPL_HAS_XXX_TRAIT_DEF(adapted_variant_tag)
  25. }
  26. template <typename T, typename Enable = void>
  27. struct is_variant
  28. : detail::has_adapted_variant_tag<T>
  29. {};
  30. template <BOOST_VARIANT_ENUM_PARAMS(typename T)>
  31. struct is_variant<boost::variant<BOOST_VARIANT_ENUM_PARAMS(T)>>
  32. : mpl::true_
  33. {};
  34. }}}}
  35. #endif