/Src/Dependencies/Boost/boost/fusion/container/deque/detail/at_impl.hpp

http://hadesmem.googlecode.com/ · C++ Header · 59 lines · 42 code · 10 blank · 7 comment · 0 complexity · 07feb25a3617b5c4dbc121579ef75a58 MD5 · raw file

  1. /*=============================================================================
  2. Copyright (c) 2001-2006 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_AT_IMPL_09122006_2017)
  8. #define BOOST_FUSION_DEQUE_AT_IMPL_09122006_2017
  9. #include <boost/fusion/container/deque/detail/keyed_element.hpp>
  10. #include <boost/mpl/eval_if.hpp>
  11. #include <boost/mpl/equal_to.hpp>
  12. #include <boost/mpl/assert.hpp>
  13. #include <boost/mpl/identity.hpp>
  14. #include <boost/type_traits/is_const.hpp>
  15. #include <boost/type_traits/add_const.hpp>
  16. #include <boost/type_traits/add_reference.hpp>
  17. namespace boost { namespace fusion {
  18. struct deque_tag;
  19. namespace extension
  20. {
  21. template<typename T>
  22. struct at_impl;
  23. template<>
  24. struct at_impl<deque_tag>
  25. {
  26. template<typename Sequence, typename N>
  27. struct apply
  28. {
  29. typedef typename Sequence::next_up next_up;
  30. typedef typename Sequence::next_down next_down;
  31. BOOST_MPL_ASSERT_RELATION(next_down::value, !=, next_up::value);
  32. typedef mpl::plus<next_down, mpl::int_<1> > offset;
  33. typedef mpl::int_<mpl::plus<N, offset>::value> adjusted_index;
  34. typedef typename detail::keyed_element_value_at<Sequence, adjusted_index>::type element_type;
  35. typedef typename add_reference<
  36. typename mpl::eval_if<
  37. is_const<Sequence>,
  38. add_const<element_type>,
  39. mpl::identity<element_type> >::type>::type type;
  40. static type call(Sequence& seq)
  41. {
  42. return seq.get(adjusted_index());
  43. }
  44. };
  45. };
  46. }
  47. }}
  48. #endif