1 | /*============================================================================= |
---|---|
2 | Copyright (c) 2001-2011 Joel de Guzman |
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(FUSION_IS_SEQUENCE_05052005_1002) |
8 | #define FUSION_IS_SEQUENCE_05052005_1002 |
9 | |
10 | #include <boost/fusion/support/config.hpp> |
11 | #include <boost/fusion/support/sequence_base.hpp> |
12 | #include <boost/fusion/support/tag_of.hpp> |
13 | #include <boost/mpl/is_sequence.hpp> |
14 | #include <boost/mpl/or.hpp> |
15 | #include <boost/mpl/bool.hpp> |
16 | #include <boost/type_traits/is_convertible.hpp> |
17 | #include <boost/type_traits/is_same.hpp> |
18 | |
19 | namespace boost { namespace fusion |
20 | { |
21 | // Special tags: |
22 | struct non_fusion_tag; |
23 | struct boost_tuple_tag; // boost::tuples::tuple tag |
24 | struct boost_array_tag; // boost::array tag |
25 | struct mpl_sequence_tag; // mpl sequence tag |
26 | struct std_pair_tag; // std::pair tag |
27 | |
28 | namespace extension |
29 | { |
30 | template <typename T> |
31 | struct is_sequence_impl |
32 | { |
33 | template <typename Sequence> |
34 | struct apply |
35 | : is_convertible<Sequence, fusion::detail::from_sequence_convertible_type> |
36 | {}; |
37 | }; |
38 | |
39 | template <> |
40 | struct is_sequence_impl<non_fusion_tag> |
41 | { |
42 | template <typename T> |
43 | struct apply : mpl::false_ {}; |
44 | }; |
45 | |
46 | template <> |
47 | struct is_sequence_impl<boost_tuple_tag>; |
48 | |
49 | template <> |
50 | struct is_sequence_impl<boost_array_tag>; |
51 | |
52 | template <> |
53 | struct is_sequence_impl<mpl_sequence_tag>; |
54 | |
55 | template <> |
56 | struct is_sequence_impl<std_pair_tag>; |
57 | } |
58 | |
59 | namespace traits |
60 | { |
61 | template <typename T> |
62 | struct is_sequence |
63 | : mpl::bool_< |
64 | (bool)extension::is_sequence_impl< |
65 | typename fusion::detail::tag_of<T>::type |
66 | >::template apply<T>::type::value |
67 | > |
68 | {}; |
69 | |
70 | template <typename Sequence, typename Enable = void> |
71 | struct is_native_fusion_sequence |
72 | : is_convertible<Sequence, fusion::detail::from_sequence_convertible_type> |
73 | {}; |
74 | } |
75 | }} |
76 | |
77 | #endif |
78 |