/Src/Dependencies/Boost/boost/spirit/home/phoenix/operator/self.hpp

http://hadesmem.googlecode.com/ · C++ Header · 75 lines · 58 code · 11 blank · 6 comment · 0 complexity · 75c5da5f8b7a2d9da50e6d4fd0e24520 MD5 · raw file

  1. /*=============================================================================
  2. Copyright (c) 2001-2007 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. #ifndef PHOENIX_OPERATOR_SELF_HPP
  7. #define PHOENIX_OPERATOR_SELF_HPP
  8. #include <boost/spirit/home/phoenix/core/composite.hpp>
  9. #include <boost/spirit/home/phoenix/core/compose.hpp>
  10. #include <boost/spirit/home/phoenix/detail/type_deduction.hpp>
  11. #include <boost/spirit/home/phoenix/operator/detail/unary_eval.hpp>
  12. #include <boost/spirit/home/phoenix/operator/detail/unary_compose.hpp>
  13. #include <boost/spirit/home/phoenix/operator/detail/binary_eval.hpp>
  14. #include <boost/spirit/home/phoenix/operator/detail/binary_compose.hpp>
  15. namespace boost { namespace phoenix
  16. {
  17. struct reference_eval;
  18. struct dereference_eval;
  19. struct assign_eval;
  20. struct index_eval;
  21. BOOST_UNARY_RESULT_OF(&x, result_of_reference)
  22. BOOST_UNARY_RESULT_OF(*x, result_of_dereference)
  23. BOOST_BINARY_RESULT_OF(x = y, result_of_assign)
  24. BOOST_ASYMMETRIC_BINARY_RESULT_OF(x[y], result_of_index)
  25. namespace detail
  26. {
  27. template <typename T0, typename T1>
  28. struct make_assign_composite
  29. {
  30. typedef actor<typename as_composite<assign_eval, T0, T1>::type> type;
  31. };
  32. template <typename T0, typename T1>
  33. struct make_index_composite
  34. {
  35. typedef actor<typename as_composite<index_eval, T0, T1>::type> type;
  36. };
  37. }
  38. template <typename Base>
  39. template <typename T1>
  40. typename detail::make_assign_composite<actor<Base>, T1>::type
  41. actor<Base>::operator=(T1 const& a1) const
  42. {
  43. return compose<assign_eval>(*this, a1);
  44. }
  45. template <typename Base>
  46. template <typename T1>
  47. typename detail::make_index_composite<actor<Base>, T1>::type
  48. actor<Base>::operator[](T1 const& a1) const
  49. {
  50. return compose<index_eval>(*this, a1);
  51. }
  52. #define x a0.eval(env)
  53. #define y a1.eval(env)
  54. PHOENIX_UNARY_EVAL(reference_eval, result_of_reference, &x)
  55. PHOENIX_UNARY_EVAL(dereference_eval, result_of_dereference, *x)
  56. PHOENIX_UNARY_COMPOSE(reference_eval, &)
  57. PHOENIX_UNARY_COMPOSE(dereference_eval, *)
  58. PHOENIX_BINARY_EVAL(assign_eval, result_of_assign, x = y)
  59. PHOENIX_BINARY_EVAL(index_eval, result_of_index, x[y])
  60. }}
  61. #undef x
  62. #undef y
  63. #endif