| 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_VIEW_03202006_0015) |
| 8 | #define FUSION_IS_VIEW_03202006_0015 |
| 9 | |
| 10 | #include <boost/fusion/support/config.hpp> |
| 11 | #include <boost/mpl/bool.hpp> |
| 12 | #include <boost/fusion/support/tag_of.hpp> |
| 13 | |
| 14 | namespace boost { namespace fusion |
| 15 | { |
| 16 | // Special tags: |
| 17 | struct non_fusion_tag; |
| 18 | struct sequence_facade_tag; |
| 19 | struct boost_tuple_tag; // boost::tuples::tuple tag |
| 20 | struct boost_array_tag; // boost::array tag |
| 21 | struct mpl_sequence_tag; // mpl sequence tag |
| 22 | struct std_pair_tag; // std::pair tag |
| 23 | |
| 24 | namespace extension |
| 25 | { |
| 26 | template<typename Tag> |
| 27 | struct is_view_impl |
| 28 | { |
| 29 | template <typename T> |
| 30 | struct apply |
| 31 | { |
| 32 | typedef typename T::is_view type; |
| 33 | }; |
| 34 | }; |
| 35 | |
| 36 | template <> |
| 37 | struct is_view_impl<non_fusion_tag> |
| 38 | { |
| 39 | template <typename T> |
| 40 | struct apply : mpl::false_ {}; |
| 41 | }; |
| 42 | |
| 43 | template <> |
| 44 | struct is_view_impl<sequence_facade_tag> |
| 45 | { |
| 46 | template <typename Sequence> |
| 47 | struct apply : Sequence::is_view {}; |
| 48 | }; |
| 49 | |
| 50 | template <> |
| 51 | struct is_view_impl<boost_tuple_tag>; |
| 52 | |
| 53 | template <> |
| 54 | struct is_view_impl<boost_array_tag>; |
| 55 | |
| 56 | template <> |
| 57 | struct is_view_impl<mpl_sequence_tag>; |
| 58 | |
| 59 | template <> |
| 60 | struct is_view_impl<std_pair_tag>; |
| 61 | } |
| 62 | |
| 63 | namespace traits |
| 64 | { |
| 65 | template <typename T> |
| 66 | struct is_view : |
| 67 | mpl::bool_< |
| 68 | (bool)extension::is_view_impl<typename fusion::detail::tag_of<T>::type>:: |
| 69 | template apply<T>::type::value |
| 70 | > |
| 71 | {}; |
| 72 | } |
| 73 | }} |
| 74 | |
| 75 | #endif |
| 76 |
