has_semantic_action.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Hartmut Kaiser
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #if !defined(BOOST_SPIRIT_HAS_SEMANTIC_ACTION_SEP_20_2009_0626PM)
  7. #define BOOST_SPIRIT_HAS_SEMANTIC_ACTION_SEP_20_2009_0626PM
  8. #if defined(_MSC_VER)
  9. #pragma once
  10. #endif
  11. #include <boost/mpl/bool.hpp>
  12. #include <boost/mpl/or.hpp>
  13. #include <boost/mpl/not.hpp>
  14. #include <boost/mpl/find_if.hpp>
  15. #include <boost/type_traits/is_same.hpp>
  16. namespace boost { namespace spirit { namespace traits
  17. {
  18. // finding out, whether a component contains a semantic action
  19. template <typename T, typename Enable = void>
  20. struct has_semantic_action
  21. : mpl::false_ {};
  22. template <typename Subject>
  23. struct unary_has_semantic_action
  24. : has_semantic_action<Subject> {};
  25. template <typename Left, typename Right>
  26. struct binary_has_semantic_action
  27. : mpl::or_<has_semantic_action<Left>, has_semantic_action<Right> > {};
  28. template <typename Elements>
  29. struct nary_has_semantic_action
  30. : mpl::not_<
  31. is_same<
  32. typename mpl::find_if<
  33. Elements, has_semantic_action<mpl::_>
  34. >::type
  35. , typename mpl::end<Elements>::type
  36. >
  37. > {};
  38. }}}
  39. #endif