| 1 | /*============================================================================= |
|---|---|
| 2 | Copyright (c) 2001-2011 Joel de Guzman |
| 3 | Copyright (c) 2011 Eric Niebler |
| 4 | |
| 5 | Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 6 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 7 | ==============================================================================*/ |
| 8 | #if !defined(BOOST_FUSION_SINGLE_VIEW_05052005_0335) |
| 9 | #define BOOST_FUSION_SINGLE_VIEW_05052005_0335 |
| 10 | |
| 11 | #include <boost/fusion/support/config.hpp> |
| 12 | #include <boost/fusion/support/detail/access.hpp> |
| 13 | #include <boost/fusion/support/detail/as_fusion_element.hpp> |
| 14 | #include <boost/fusion/support/sequence_base.hpp> |
| 15 | #include <boost/fusion/view/single_view/single_view_iterator.hpp> |
| 16 | #include <boost/fusion/view/single_view/detail/at_impl.hpp> |
| 17 | #include <boost/fusion/view/single_view/detail/begin_impl.hpp> |
| 18 | #include <boost/fusion/view/single_view/detail/end_impl.hpp> |
| 19 | #include <boost/fusion/view/single_view/detail/size_impl.hpp> |
| 20 | #include <boost/fusion/view/single_view/detail/value_at_impl.hpp> |
| 21 | #include <boost/mpl/bool.hpp> |
| 22 | #include <boost/mpl/int.hpp> |
| 23 | #include <boost/config.hpp> |
| 24 | |
| 25 | #if defined (BOOST_MSVC) |
| 26 | # pragma warning(push) |
| 27 | # pragma warning (disable: 4512) // assignment operator could not be generated. |
| 28 | #endif |
| 29 | |
| 30 | namespace boost { namespace fusion |
| 31 | { |
| 32 | struct single_view_tag; |
| 33 | struct random_access_traversal_tag; |
| 34 | struct fusion_sequence_tag; |
| 35 | |
| 36 | template <typename T> |
| 37 | struct single_view : sequence_base<single_view<T> > |
| 38 | { |
| 39 | typedef single_view_tag fusion_tag; |
| 40 | typedef fusion_sequence_tag tag; // this gets picked up by MPL |
| 41 | typedef random_access_traversal_tag category; |
| 42 | typedef mpl::true_ is_view; |
| 43 | typedef mpl::int_<1> size; |
| 44 | typedef T value_type; |
| 45 | |
| 46 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
| 47 | single_view() |
| 48 | : val() {} |
| 49 | |
| 50 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
| 51 | explicit single_view(typename detail::call_param<T>::type in_val) |
| 52 | : val(in_val) {} |
| 53 | |
| 54 | value_type val; |
| 55 | }; |
| 56 | |
| 57 | template <typename T> |
| 58 | BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED |
| 59 | inline single_view<typename detail::as_fusion_element<T>::type> |
| 60 | make_single_view(T const& v) |
| 61 | { |
| 62 | return single_view<typename detail::as_fusion_element<T>::type>(v); |
| 63 | } |
| 64 | }} |
| 65 | |
| 66 | #if defined (BOOST_MSVC) |
| 67 | # pragma warning(pop) |
| 68 | #endif |
| 69 | |
| 70 | #endif |
| 71 | |
| 72 | |
| 73 |
