handles_container.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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_HANDLES_CONTAINER_DEC_18_2010_0920AM)
  7. #define BOOST_SPIRIT_HANDLES_CONTAINER_DEC_18_2010_0920AM
  8. #if defined(_MSC_VER)
  9. #pragma once
  10. #endif
  11. #include <boost/spirit/home/support/attributes_fwd.hpp>
  12. #include <boost/mpl/bool.hpp>
  13. #include <boost/mpl/or.hpp>
  14. #include <boost/mpl/not.hpp>
  15. #include <boost/mpl/find_if.hpp>
  16. #include <boost/type_traits/is_same.hpp>
  17. namespace boost { namespace spirit { namespace traits
  18. {
  19. // Finds out whether a component handles container attributes intrinsically
  20. // (or whether container attributes need to be split up separately).
  21. template <typename T, typename Attribute, typename Context
  22. , typename Iterator, typename Enable>
  23. struct handles_container : mpl::false_ {};
  24. template <typename Subject, typename Attribute, typename Context
  25. , typename Iterator>
  26. struct unary_handles_container
  27. : handles_container<Subject, Attribute, Context, Iterator> {};
  28. template <typename Left, typename Right, typename Attribute
  29. , typename Context, typename Iterator>
  30. struct binary_handles_container
  31. : mpl::or_<
  32. handles_container<Left, Attribute, Context, Iterator>
  33. , handles_container<Right, Attribute, Context, Iterator> >
  34. {};
  35. template <typename Elements, typename Attribute, typename Context
  36. , typename Iterator>
  37. struct nary_handles_container
  38. : mpl::not_<
  39. is_same<
  40. typename mpl::find_if<
  41. Elements, handles_container<mpl::_, Attribute
  42. , Context, Iterator>
  43. >::type
  44. , typename mpl::end<Elements>::type> >
  45. {};
  46. }}}
  47. #endif