at.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*==============================================================================
  2. Copyright (c) 2005-2008 Hartmut Kaiser
  3. Copyright (c) 2005-2010 Joel de Guzman
  4. Copyright (c) 2010 Thomas Heller
  5. Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. ==============================================================================*/
  8. #ifndef BOOST_PHOENIX_FUSION_AT_HPP
  9. #define BOOST_PHOENIX_FUSION_AT_HPP
  10. #include <boost/phoenix/core/limits.hpp>
  11. #include <boost/fusion/sequence/intrinsic/at_c.hpp>
  12. #include <boost/phoenix/core/expression.hpp>
  13. #include <boost/phoenix/core/meta_grammar.hpp>
  14. #include <boost/type_traits/remove_reference.hpp>
  15. BOOST_PHOENIX_DEFINE_EXPRESSION(
  16. (boost)(phoenix)(at_c)
  17. , (proto::terminal<proto::_>)
  18. (meta_grammar)
  19. )
  20. namespace boost { namespace phoenix
  21. {
  22. template <typename Dummy>
  23. struct default_actions::when<rule::at_c, Dummy>
  24. : proto::call<
  25. proto::functional::at(
  26. evaluator(proto::_child_c<1>)
  27. , proto::_value(proto::_child_c<0>)
  28. )
  29. >
  30. {};
  31. template <int N, typename Tuple>
  32. inline
  33. typename expression::at_c<mpl::int_<N>, Tuple>::type const
  34. at_c(Tuple const& tuple)
  35. {
  36. return
  37. expression::
  38. at_c<mpl::int_<N>, Tuple>::
  39. make(mpl::int_<N>(), tuple);
  40. }
  41. }}
  42. #endif