PageRenderTime 19ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

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