value_at_impl.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*=============================================================================
  2. Copyright (c) 2005-2012 Joel de Guzman
  3. Copyright (c) 2005-2006 Dan Marsden
  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_DEQUE_VALUE_AT_IMPL_08122006_0756)
  8. #define BOOST_FUSION_DEQUE_VALUE_AT_IMPL_08122006_0756
  9. #include <boost/fusion/support/config.hpp>
  10. #include <boost/fusion/container/deque/detail/keyed_element.hpp>
  11. #include <boost/mpl/equal_to.hpp>
  12. #include <boost/mpl/assert.hpp>
  13. namespace boost { namespace fusion
  14. {
  15. struct deque_tag;
  16. namespace extension
  17. {
  18. template<typename T>
  19. struct value_at_impl;
  20. template<>
  21. struct value_at_impl<deque_tag>
  22. {
  23. template<typename Sequence, typename N>
  24. struct apply
  25. {
  26. typedef typename Sequence::next_up next_up;
  27. typedef typename Sequence::next_down next_down;
  28. BOOST_MPL_ASSERT_RELATION(next_down::value, !=, next_up::value);
  29. static int const offset = next_down::value + 1;
  30. typedef mpl::int_<(N::value + offset)> adjusted_index;
  31. typedef typename
  32. detail::keyed_element_value_at<Sequence, adjusted_index>::type
  33. type;
  34. };
  35. };
  36. }
  37. }}
  38. #endif