single_view.hpp 2.2 KB

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