summaryrefslogtreecommitdiff
path: root/boost/spirit/home/x3/support/traits/tuple_traits.hpp
blob: 46e4246b74717c9fe4447f34bfe82607c95f6aa6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*=============================================================================
    Copyright (c) 2001-2014 Joel de Guzman

    Distributed under the Boost Software License, Version 1.0. (See accompanying
    file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
================================================_==============================*/
#if !defined(BOOST_SPIRIT_X3_TUPLE_TRAITS_JANUARY_2012_1132PM)
#define BOOST_SPIRIT_X3_TUPLE_TRAITS_JANUARY_2012_1132PM

#include <boost/fusion/include/is_sequence.hpp>
#include <boost/fusion/include/size.hpp>
#include <boost/mpl/bool.hpp>
#include <boost/mpl/and.hpp>

namespace boost { namespace spirit { namespace x3 { namespace traits
{
    template <typename A, typename B>
    struct has_same_size
      : mpl::bool_<(
            fusion::result_of::size<A>::value ==
            fusion::result_of::size<B>::value
        )>
    {};

    template <typename T, std::size_t N>
    struct has_size
      : mpl::bool_<(fusion::result_of::size<T>::value == N)>
    {};

    template <typename A, typename B>
    struct is_same_size_sequence
      : mpl::and_<
            fusion::traits::is_sequence<A>
          , fusion::traits::is_sequence<B>
          , has_same_size<A, B>
        >
    {};

    template <typename Seq>
    struct is_size_one_sequence
      : mpl::and_<
            fusion::traits::is_sequence<Seq>
          , has_size<Seq, 1>
        >
    {};
}}}}

#endif