single_view.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  3. Copyright (c) 2011 Eric Niebler
  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_FUSION_SINGLE_VIEW_05052005_0335)
  8. #define BOOST_FUSION_SINGLE_VIEW_05052005_0335
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/fusion/support/detail/access.hpp>
  11. #include <boost/fusion/support/detail/as_fusion_element.hpp>
  12. #include <boost/fusion/support/sequence_base.hpp>
  13. #include <boost/fusion/view/single_view/single_view_iterator.hpp>
  14. #include <boost/fusion/view/single_view/detail/at_impl.hpp>
  15. #include <boost/fusion/view/single_view/detail/begin_impl.hpp>
  16. #include <boost/fusion/view/single_view/detail/end_impl.hpp>
  17. #include <boost/fusion/view/single_view/detail/size_impl.hpp>
  18. #include <boost/fusion/view/single_view/detail/value_at_impl.hpp>
  19. #include <boost/mpl/bool.hpp>
  20. #include <boost/mpl/int.hpp>
  21. #include <boost/config.hpp>
  22. #if defined (BOOST_MSVC)
  23. # pragma warning(push)
  24. # pragma warning (disable: 4512) // assignment operator could not be generated.
  25. #endif
  26. namespace boost { namespace fusion
  27. {
  28. struct single_view_tag;
  29. struct random_access_traversal_tag;
  30. struct fusion_sequence_tag;
  31. template <typename T>
  32. struct single_view : sequence_base<single_view<T> >
  33. {
  34. typedef single_view_tag fusion_tag;
  35. typedef fusion_sequence_tag tag; // this gets picked up by MPL
  36. typedef random_access_traversal_tag category;
  37. typedef mpl::true_ is_view;
  38. typedef mpl::int_<1> size;
  39. typedef T value_type;
  40. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  41. single_view()
  42. : val() {}
  43. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  44. explicit single_view(typename detail::call_param<T>::type in_val)
  45. : val(in_val) {}
  46. value_type val;
  47. };
  48. template <typename T>
  49. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  50. inline single_view<typename detail::as_fusion_element<T>::type>
  51. make_single_view(T const& v)
  52. {
  53. return single_view<typename detail::as_fusion_element<T>::type>(v);
  54. }
  55. }}
  56. #if defined (BOOST_MSVC)
  57. # pragma warning(pop)
  58. #endif
  59. #endif