at_impl.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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_AT_IMPL_05042005_0741)
  7. #define FUSION_AT_IMPL_05042005_0741
  8. #include <boost/fusion/support/config.hpp>
  9. #include <boost/fusion/support/detail/access.hpp>
  10. #include <boost/fusion/container/vector/detail/value_at_impl.hpp>
  11. #include <boost/static_assert.hpp>
  12. namespace boost { namespace fusion
  13. {
  14. struct vector_tag;
  15. namespace extension
  16. {
  17. template <typename Tag>
  18. struct at_impl;
  19. template <>
  20. struct at_impl<vector_tag>
  21. {
  22. template <typename Sequence, typename N>
  23. struct apply
  24. {
  25. typedef typename value_at_impl<vector_tag>::template apply<Sequence, N>::type element;
  26. typedef typename detail::ref_result<element>::type type;
  27. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  28. static type
  29. call(Sequence& v)
  30. {
  31. BOOST_STATIC_ASSERT((N::value < Sequence::size::value));
  32. return v.at_impl(N());
  33. }
  34. };
  35. template <typename Sequence, typename N>
  36. struct apply <Sequence const, N>
  37. {
  38. typedef typename value_at_impl<vector_tag>::template apply<Sequence, N>::type element;
  39. typedef typename detail::cref_result<element>::type type;
  40. BOOST_CONSTEXPR BOOST_FUSION_GPU_ENABLED
  41. static type
  42. call(Sequence const& v)
  43. {
  44. BOOST_STATIC_ASSERT((N::value < Sequence::size::value));
  45. return v.at_impl(N());
  46. }
  47. };
  48. };
  49. }
  50. }}
  51. #endif