convert.hpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. /*=============================================================================
  2. Copyright (c) 2001-2011 Joel de Guzman
  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. #if !defined(FUSION_CONVERT_09222005_1104)
  7. #define FUSION_CONVERT_09222005_1104
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/container/vector/detail/as_vector.hpp>
  10. #include <boost/fusion/container/vector/detail/convert_impl.hpp>
  11. #include <boost/fusion/container/vector/vector.hpp>
  12. #include <boost/fusion/sequence/intrinsic/begin.hpp>
  13. #include <boost/fusion/sequence/intrinsic/size.hpp>
  14. namespace boost { namespace fusion
  15. {
  16. namespace result_of
  17. {
  18. template <typename Sequence>
  19. struct as_vector
  20. {
  21. typedef typename detail::as_vector<result_of::size<Sequence>::value> gen;
  22. typedef typename gen::
  23. template apply<typename result_of::begin<Sequence>::type>::type
  24. type;
  25. };
  26. }
  27. template <typename Sequence>
  28. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  29. inline typename result_of::as_vector<Sequence>::type
  30. as_vector(Sequence& seq)
  31. {
  32. typedef typename result_of::as_vector<Sequence>::gen gen;
  33. return gen::call(fusion::begin(seq));
  34. }
  35. template <typename Sequence>
  36. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  37. inline typename result_of::as_vector<Sequence const>::type
  38. as_vector(Sequence const& seq)
  39. {
  40. typedef typename result_of::as_vector<Sequence const>::gen gen;
  41. return gen::call(fusion::begin(seq));
  42. }
  43. }}
  44. #endif