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