nview_impl.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*=============================================================================
  2. Copyright (c) 2014 Kohei Takahashi
  3. Distributed under the Boost Software License, Version 1.0. (See accompanying
  4. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. ==============================================================================*/
  6. #ifndef BOOST_FUSION_NVIEW_IMPL_17122014_1948
  7. #define BOOST_FUSION_NVIEW_IMPL_17122014_1948
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/container/vector/detail/config.hpp>
  10. ///////////////////////////////////////////////////////////////////////////////
  11. // Without variadics, we will use the PP version
  12. ///////////////////////////////////////////////////////////////////////////////
  13. #if !defined(BOOST_FUSION_HAS_VARIADIC_VECTOR)
  14. # include <boost/fusion/view/nview/detail/cpp03/nview_impl.hpp>
  15. #else
  16. ///////////////////////////////////////////////////////////////////////////////
  17. // C++11 interface
  18. ///////////////////////////////////////////////////////////////////////////////
  19. #include <boost/fusion/container/vector.hpp>
  20. #include <boost/mpl/int.hpp>
  21. namespace boost { namespace fusion
  22. {
  23. namespace result_of
  24. {
  25. template <typename Sequence, int ...I>
  26. struct as_nview
  27. {
  28. typedef vector<mpl::int_<I>...> index_type;
  29. typedef nview<Sequence, index_type> type;
  30. };
  31. }
  32. template <int ...I, typename Sequence>
  33. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  34. inline nview<Sequence, vector<mpl::int_<I>...> >
  35. as_nview(Sequence& s)
  36. {
  37. typedef vector<mpl::int_<I>...> index_type;
  38. return nview<Sequence, index_type>(s);
  39. }
  40. }}
  41. #endif
  42. #endif