Update of /cvsroot/boost/boost/boost/xpressive/proto
In directory
sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv16155/boost/xpressive/proto
Modified Files:
compile.hpp context.hpp expr.hpp extends.hpp make_expr.hpp
traits.hpp
Log Message:
as_arg and as_expr are const-sensitive
Index: compile.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/compile.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- compile.hpp 3 Feb 2007 00:14:33 -0000 1.5
+++ compile.hpp 3 Feb 2007 09:04:30 -0000 1.6
@@ -22,9 +22,8 @@
template<typename Expr, typename State, typename Visitor, typename
DomainTag>
struct compile
{
- typedef typename result_of::unref<typename
result_of::as_expr<Expr>::type>::type expr_type;
- typedef compiler<typename tag_of<expr_type>::type, DomainTag>
compiler;
- typedef typename compiler::BOOST_NESTED_TEMPLATE apply<expr_type,
State, Visitor>::type type;
+ typedef compiler<typename tag_of<Expr>::type, DomainTag> compiler;
+ typedef typename compiler::BOOST_NESTED_TEMPLATE apply<Expr,
State, Visitor>::type type;
};
}
@@ -49,9 +48,8 @@
typename result_of::compile<Expr, State, Visitor, DomainTag>::type
operator()(Expr const &expr, State const &state, Visitor &visitor,
DomainTag) const
{
- typedef typename result_of::unref<typename
result_of::as_expr<Expr>::type>::type expr_type;
- typedef compiler<typename tag_of<expr_type>::type, DomainTag>
compiler;
- return compiler::call(proto::unref(proto::as_expr(expr)),
state, visitor);
+ typedef compiler<typename tag_of<Expr>::type, DomainTag>
compiler;
+ return compiler::call(expr, state, visitor);
}
};
}
Index: context.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/context.hpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- context.hpp 3 Feb 2007 00:14:33 -0000 1.4
+++ context.hpp 3 Feb 2007 09:04:30 -0000 1.5
@@ -1,272 +1,310 @@
-///////////////////////////////////////////////////////////////////////////////
-/// \file context.hpp
-/// Definintion of context\<\>, a default evaluation context for
-/// expr\<\>::eval() that uses Boost.Typeof to deduce return types
-/// of the built-in operators.
-//
-// Copyright 2004 Eric Niebler. Distributed under the Boost
-// Software License, Version 1.0. (See accompanying file
-// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
+#ifndef BOOST_PP_IS_ITERATING
+
///////////////////////////////////////////////////////////////////////////////
+ /// \file context.hpp
+ /// Definintion of context\<\>, a default evaluation context for
+ /// expr\<\>::eval() that uses Boost.Typeof to deduce return types
+ /// of the built-in operators.
+ //
+ // Copyright 2004 Eric Niebler. Distributed under the Boost
+ // Software License, Version 1.0. (See accompanying file
+ // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
-#ifndef BOOST_PROTO_CONTEXT_HPP_EAN_01_08_2007
-#define BOOST_PROTO_CONTEXT_HPP_EAN_01_08_2007
+ #ifndef BOOST_PROTO_CONTEXT_HPP_EAN_01_08_2007
+ #define BOOST_PROTO_CONTEXT_HPP_EAN_01_08_2007
-#include <boost/xpressive/proto/detail/prefix.hpp>
-#include <boost/preprocessor/iteration/local.hpp>
-#include <boost/preprocessor/punctuation/comma.hpp>
-#include <boost/preprocessor/facilities/intercept.hpp>
-#include <boost/preprocessor/repetition/enum_trailing_params.hpp>
-#include <boost/preprocessor/repetition/enum_binary_params.hpp>
-#include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
-#include <boost/preprocessor/repetition/enum_shifted_params.hpp>
-#include <boost/preprocessor/repetition/enum_shifted_binary_params.hpp>
-#include <boost/config.hpp>
-#include <boost/detail/workaround.hpp>
-#include <boost/mpl/if.hpp>
-#include <boost/typeof/typeof.hpp>
-#include <boost/utility/result_of.hpp>
-#include <boost/type_traits/is_same.hpp>
-#include <boost/type_traits/add_const.hpp>
-#include <boost/type_traits/add_reference.hpp>
-#include <boost/xpressive/proto/proto_fwd.hpp>
-#include <boost/xpressive/proto/tags.hpp>
-#include <boost/xpressive/proto/detail/suffix.hpp>
+ #include <boost/xpressive/proto/detail/prefix.hpp>
+ #include <boost/preprocessor/cat.hpp>
+ #include <boost/preprocessor/iteration/iterate.hpp>
+ #include <boost/preprocessor/punctuation/comma.hpp>
+ #include <boost/preprocessor/facilities/intercept.hpp>
+ #include <boost/preprocessor/repetition/enum_trailing_params.hpp>
+ #include <boost/preprocessor/repetition/enum_binary_params.hpp>
+ #include <boost/preprocessor/repetition/enum_trailing_binary_params.hpp>
+ #include <boost/preprocessor/repetition/enum_shifted_params.hpp>
+ #include <boost/preprocessor/repetition/enum_shifted_binary_params.hpp>
+ #include <boost/config.hpp>
+ #include <boost/detail/workaround.hpp>
+ #include <boost/mpl/if.hpp>
+ #include <boost/typeof/typeof.hpp>
+ #include <boost/utility/result_of.hpp>
+ #include <boost/type_traits/is_same.hpp>
+ #include <boost/type_traits/is_function.hpp>
+ #include <boost/type_traits/add_const.hpp>
+ #include <boost/type_traits/add_reference.hpp>
+ #include <boost/xpressive/proto/proto_fwd.hpp>
+ #include <boost/xpressive/proto/tags.hpp>
+ #include <boost/xpressive/proto/detail/suffix.hpp>
-namespace boost { namespace proto
-{
- namespace detail
+ namespace boost { namespace proto
{
- template<typename T> T make();
+ namespace detail
+ {
+ template<typename T> T make();
- template<typename T>
- char check_reference(T &);
+ template<typename T>
+ char check_reference(T &);
- template<typename T>
- char (&check_reference(T const &))[2];
+ template<typename T>
+ char (&check_reference(T const &))[2];
- template<typename T>
- struct as_param
- : add_reference<typename add_const<T>::type>
- {};
- }
+ template<typename T>
+ struct as_param
+ : add_reference<typename add_const<T>::type>
+ {};
- template<typename Derived>
- struct context
- {
- typedef typename mpl::if_<
- is_same<Derived, void>
- , context
- , Derived
- >::type derived_type;
+ template<typename T, typename U = T>
+ struct result_of_fixup
+ : mpl::if_<is_function<T>, T *, U>
+ {};
- derived_type &cast()
- {
- return *static_cast<derived_type *>(this);
+ template<typename T, typename U>
+ struct result_of_fixup<T &, U>
+ : result_of_fixup<T, T>
+ {};
+
+ template<typename T, typename U>
+ struct result_of_fixup<T *, U>
+ : result_of_fixup<T, U>
+ {};
+
+ template<typename T, typename U>
+ struct result_of_fixup<T const, U>
+ : result_of_fixup<T, U>
+ {};
+
+ //// Tests for result_of_fixup
+ //struct bar {};
+ //BOOST_MPL_ASSERT((is_same<bar,
result_of_fixup<bar>::type>));
+ //BOOST_MPL_ASSERT((is_same<bar const, result_of_fixup<bar
const>::type>));
+ //BOOST_MPL_ASSERT((is_same<bar, result_of_fixup<bar
&>::type>));
+ //BOOST_MPL_ASSERT((is_same<bar const, result_of_fixup<bar const
&>::type>));
+ //BOOST_MPL_ASSERT((is_same<void(*)(),
result_of_fixup<void(*)()>::type>));
+ //BOOST_MPL_ASSERT((is_same<void(*)(), result_of_fixup<void(*
const)()>::type>));
+ //BOOST_MPL_ASSERT((is_same<void(*)(), result_of_fixup<void(*
const &)()>::type>));
+ //BOOST_MPL_ASSERT((is_same<void(*)(),
result_of_fixup<void(&)()>::type>));
}
- template<typename Sig>
- struct result;
+#define BOOST_PROTO_DECLTYPE_NESTED_TYPEDEF_TPL(Nested, Expr)\
+ BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested_and_hidden, Expr)\
+ struct Nested\
+ : mpl::if_c<\
+ 1==sizeof(detail::check_reference(Expr))\
+ , typename nested_and_hidden::type &\
+ , typename nested_and_hidden::type\
+ >\
+ {};\
+ /**/
- template<typename This, typename A0>
- struct result<This(proto::tag::terminal, A0 &)>
+ template<typename Derived>
+ struct context
{
- typedef A0 &type;
- };
+ typedef typename mpl::if_<
+ is_same<Derived, void>
+ , context
+ , Derived
+ >::type derived_type;
- #define BOOST_PROTO_UNARY_OP_RESULT(Op, Tag)\
- template<typename This, typename A0>\
- struct result<This(Tag, A0 &)>\
- {\
- typedef typename proto::result_of::eval<A0, derived_type>::type
eval_type0;\
- BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, (Op
detail::make<eval_type0>()))\
- typedef typename mpl::if_c<\
- 1==sizeof(detail::check_reference((Op
detail::make<eval_type0>())))\
- , typename nested::type &\
- , typename nested::type\
- >::type type;\
- static type call(typename detail::as_param<eval_type0>::type a0)\
+ derived_type &cast()
+ {
+ return *static_cast<derived_type *>(this);
+ }
+
+ template<typename Sig>
+ struct result;
+
+ template<typename This, typename A0>
+ struct result<This(proto::tag::terminal, A0 &)>
+ {
+ typedef A0 &type;
+ };
+
+ #define BOOST_PROTO_UNARY_OP_RESULT(Op, Tag)\
+ template<typename This, typename A0>\
+ struct result<This(Tag, A0 &)>\
{\
- return Op a0;\
+ typedef typename proto::result_of::eval<A0,
derived_type>::type eval_type0;\
+ BOOST_PROTO_DECLTYPE_NESTED_TYPEDEF_TPL(nested, (Op
detail::make<eval_type0>()))\
+ typedef typename nested::type type;\
+ static type call(typename detail::as_param<eval_type0>::type
a0)\
+ {\
+ return Op a0;\
+ }\
}\
- }
+ /**/
- #define BOOST_PROTO_BINARY_OP_RESULT(Op, Tag)\
- template<typename This, typename A0, typename A1>\
- struct result<This(Tag, A0 &, A1 &)>\
- {\
- typedef typename proto::result_of::eval<A0, derived_type>::type
eval_type0;\
- typedef typename proto::result_of::eval<A1, derived_type>::type
eval_type1;\
- BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested,
(detail::make<eval_type0>() Op detail::make<eval_type1>()))\
- typedef typename mpl::if_c<\
- 1==sizeof(detail::check_reference((detail::make<eval_type0>()
Op detail::make<eval_type1>())))\
- , typename nested::type &\
- , typename nested::type\
- >::type type;\
- static type call(typename detail::as_param<eval_type0>::type a0,
typename detail::as_param<eval_type1>::type a1)\
+ #define BOOST_PROTO_BINARY_OP_RESULT(Op, Tag)\
+ template<typename This, typename A0, typename A1>\
+ struct result<This(Tag, A0 &, A1 &)>\
{\
- return a0 Op a1;\
+ typedef typename proto::result_of::eval<A0,
derived_type>::type eval_type0;\
+ typedef typename proto::result_of::eval<A1,
derived_type>::type eval_type1;\
+ BOOST_PROTO_DECLTYPE_NESTED_TYPEDEF_TPL(nested,
(detail::make<eval_type0>() Op detail::make<eval_type1>()))\
+ typedef typename nested::type type;\
+ static type\
+ call(typename detail::as_param<eval_type0>::type a0,
typename detail::as_param<eval_type1>::type a1)\
+ {\
+ return a0 Op a1;\
+ }\
}\
- }
+ /**/
- BOOST_PROTO_UNARY_OP_RESULT(+, proto::tag::unary_plus);
- BOOST_PROTO_UNARY_OP_RESULT(-, proto::tag::unary_minus);
- BOOST_PROTO_UNARY_OP_RESULT(*, proto::tag::unary_star);
- BOOST_PROTO_UNARY_OP_RESULT(~, proto::tag::complement);
- BOOST_PROTO_UNARY_OP_RESULT(&, proto::tag::address_of);
- BOOST_PROTO_UNARY_OP_RESULT(!, proto::tag::logical_not);
- BOOST_PROTO_UNARY_OP_RESULT(++, proto::tag::pre_inc);
- BOOST_PROTO_UNARY_OP_RESULT(--, proto::tag::pre_dec);
+ // GCC will ICE if we try to evaluate the typeof an op=
expression, like (i += 1)
+ #if !BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(4))
+ #define BOOST_PROTO_BINARY_OP_ASSIGN_RESULT(Op, Tag)\
+ BOOST_PROTO_BINARY_OP_RESULT(Op, Tag)
+ #else
+ #define BOOST_PROTO_BINARY_OP_ASSIGN_RESULT(Op, Tag)\
+ template<typename This, typename A0, typename A1>\
+ struct result<This(Tag, A0 &, A1 &)>\
+ {\
+ typedef typename proto::result_of::eval<A0,
derived_type>::type eval_type0;\
+ typedef typename proto::result_of::eval<A1,
derived_type>::type eval_type1;\
+ typedef eval_type0 type;\
+ static type\
+ call(typename detail::as_param<eval_type0>::type a0,
typename detail::as_param<eval_type1>::type a1)\
+ {\
+ return a0 Op a1;\
+ }\
+ }\
+ /**/
+ #endif
- BOOST_PROTO_BINARY_OP_RESULT(<<, proto::tag::left_shift);
- BOOST_PROTO_BINARY_OP_RESULT(>>, proto::tag::right_shift);
- BOOST_PROTO_BINARY_OP_RESULT(*, proto::tag::multiply);
- BOOST_PROTO_BINARY_OP_RESULT(/, proto::tag::divide);
- BOOST_PROTO_BINARY_OP_RESULT(%, proto::tag::modulus);
- BOOST_PROTO_BINARY_OP_RESULT(+, proto::tag::add);
- BOOST_PROTO_BINARY_OP_RESULT(-, proto::tag::subtract);
- BOOST_PROTO_BINARY_OP_RESULT(<, proto::tag::less);
- BOOST_PROTO_BINARY_OP_RESULT(>, proto::tag::greater);
- BOOST_PROTO_BINARY_OP_RESULT(<=, proto::tag::less_equal);
- BOOST_PROTO_BINARY_OP_RESULT(>=, proto::tag::greater_equal);
- BOOST_PROTO_BINARY_OP_RESULT(==, proto::tag::equal);
- BOOST_PROTO_BINARY_OP_RESULT(!=, proto::tag::not_equal);
- BOOST_PROTO_BINARY_OP_RESULT(||, proto::tag::logical_or);
- BOOST_PROTO_BINARY_OP_RESULT(&&, proto::tag::logical_and);
- BOOST_PROTO_BINARY_OP_RESULT(&, proto::tag::bitwise_and);
- BOOST_PROTO_BINARY_OP_RESULT(|, proto::tag::bitwise_or);
- BOOST_PROTO_BINARY_OP_RESULT(^, proto::tag::bitwise_xor);
- BOOST_PROTO_BINARY_OP_RESULT(BOOST_PP_COMMA(), proto::tag::comma);
- BOOST_PROTO_BINARY_OP_RESULT(->*, proto::tag::mem_ptr);
- BOOST_PROTO_BINARY_OP_RESULT(=, proto::tag::assign);
+ BOOST_PROTO_UNARY_OP_RESULT(+, proto::tag::unary_plus);
+ BOOST_PROTO_UNARY_OP_RESULT(-, proto::tag::unary_minus);
+ BOOST_PROTO_UNARY_OP_RESULT(*, proto::tag::unary_star);
+ BOOST_PROTO_UNARY_OP_RESULT(~, proto::tag::complement);
+ BOOST_PROTO_UNARY_OP_RESULT(&, proto::tag::address_of);
+ BOOST_PROTO_UNARY_OP_RESULT(!, proto::tag::logical_not);
+ BOOST_PROTO_UNARY_OP_RESULT(++, proto::tag::pre_inc);
+ BOOST_PROTO_UNARY_OP_RESULT(--, proto::tag::pre_dec);
- #if !BOOST_WORKAROUND(__GNUC__, BOOST_TESTED_AT(4))
- BOOST_PROTO_BINARY_OP_RESULT(<<=, proto::tag::left_shift_assign);
- BOOST_PROTO_BINARY_OP_RESULT(>>=, proto::tag::right_shift_assign);
- BOOST_PROTO_BINARY_OP_RESULT(*=, proto::tag::multiply_assign);
- BOOST_PROTO_BINARY_OP_RESULT(/=, proto::tag::divide_assign);
- BOOST_PROTO_BINARY_OP_RESULT(%=, proto::tag::modulus_assign);
- BOOST_PROTO_BINARY_OP_RESULT(+=, proto::tag::add_assign);
- BOOST_PROTO_BINARY_OP_RESULT(-=, proto::tag::subtract_assign);
- BOOST_PROTO_BINARY_OP_RESULT(&=, proto::tag::bitwise_and_assign);
- BOOST_PROTO_BINARY_OP_RESULT(|=, proto::tag::bitwise_or_assign);
- BOOST_PROTO_BINARY_OP_RESULT(^=, proto::tag::bitwise_xor_assign);
- #endif
+ BOOST_PROTO_BINARY_OP_RESULT(<<, proto::tag::left_shift);
+ BOOST_PROTO_BINARY_OP_RESULT(>>, proto::tag::right_shift);
+ BOOST_PROTO_BINARY_OP_RESULT(*, proto::tag::multiply);
+ BOOST_PROTO_BINARY_OP_RESULT(/, proto::tag::divide);
+ BOOST_PROTO_BINARY_OP_RESULT(%, proto::tag::modulus);
+ BOOST_PROTO_BINARY_OP_RESULT(+, proto::tag::add);
+ BOOST_PROTO_BINARY_OP_RESULT(-, proto::tag::subtract);
+ BOOST_PROTO_BINARY_OP_RESULT(<, proto::tag::less);
+ BOOST_PROTO_BINARY_OP_RESULT(>, proto::tag::greater);
+ BOOST_PROTO_BINARY_OP_RESULT(<=, proto::tag::less_equal);
+ BOOST_PROTO_BINARY_OP_RESULT(>=, proto::tag::greater_equal);
+ BOOST_PROTO_BINARY_OP_RESULT(==, proto::tag::equal);
+ BOOST_PROTO_BINARY_OP_RESULT(!=, proto::tag::not_equal);
+ BOOST_PROTO_BINARY_OP_RESULT(||, proto::tag::logical_or);
+ BOOST_PROTO_BINARY_OP_RESULT(&&, proto::tag::logical_and);
+ BOOST_PROTO_BINARY_OP_RESULT(&, proto::tag::bitwise_and);
+ BOOST_PROTO_BINARY_OP_RESULT(|, proto::tag::bitwise_or);
+ BOOST_PROTO_BINARY_OP_RESULT(^, proto::tag::bitwise_xor);
+ BOOST_PROTO_BINARY_OP_RESULT(BOOST_PP_COMMA(), proto::tag::comma);
+ BOOST_PROTO_BINARY_OP_RESULT(->*, proto::tag::mem_ptr);
+ BOOST_PROTO_BINARY_OP_RESULT(=, proto::tag::assign);
- // Handle post-increment specially.
- template<typename This, typename A0>
- struct result<This(proto::tag::post_inc, A0 &)>
- {
- typedef typename proto::result_of::eval<A0, derived_type>::type
eval_type0;
- BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested,
(detail::make<eval_type0>() ++))
- typedef typename mpl::if_c<
- 1==sizeof(detail::check_reference((detail::make<eval_type0>()
++)))
- , typename nested::type &
- , typename nested::type
- >::type type;
- static type call(typename detail::as_param<eval_type0>::type a0)
+ BOOST_PROTO_BINARY_OP_ASSIGN_RESULT(<<=,
proto::tag::left_shift_assign);
+ BOOST_PROTO_BINARY_OP_ASSIGN_RESULT(>>=,
proto::tag::right_shift_assign);
+ BOOST_PROTO_BINARY_OP_ASSIGN_RESULT(*=,
proto::tag::multiply_assign);
+ BOOST_PROTO_BINARY_OP_ASSIGN_RESULT(/=, proto::tag::divide_assign);
+ BOOST_PROTO_BINARY_OP_ASSIGN_RESULT(%=,
proto::tag::modulus_assign);
+ BOOST_PROTO_BINARY_OP_ASSIGN_RESULT(+=, proto::tag::add_assign);
+ BOOST_PROTO_BINARY_OP_ASSIGN_RESULT(-=,
proto::tag::subtract_assign);
+ BOOST_PROTO_BINARY_OP_ASSIGN_RESULT(&=,
proto::tag::bitwise_and_assign);
+ BOOST_PROTO_BINARY_OP_ASSIGN_RESULT(|=,
proto::tag::bitwise_or_assign);
+ BOOST_PROTO_BINARY_OP_ASSIGN_RESULT(^=,
proto::tag::bitwise_xor_assign);
+
+ #undef BOOST_PROTO_UNARY_OP_RESULT
+ #undef BOOST_PROTO_BINARY_OP_RESULT
+ #undef BOOST_PROTO_BINARY_OP_ASSIGN_RESULT
+
+ // Handle post-increment specially.
+ template<typename This, typename A0>
+ struct result<This(proto::tag::post_inc, A0 &)>
{
- return a0 ++;
- }
- };
+ typedef typename proto::result_of::eval<A0,
derived_type>::type eval_type0;
+ BOOST_PROTO_DECLTYPE_NESTED_TYPEDEF_TPL(nested,
(detail::make<eval_type0>() ++))
+ typedef typename nested::type type;
+ static type call(typename detail::as_param<eval_type0>::type
a0)
+ {
+ return a0 ++;
+ }
+ };
- // Handle post-decrement specially.
- template<typename This, typename A0>
- struct result<This(proto::tag::post_dec, A0 &)>
- {
- typedef typename proto::result_of::eval<A0, derived_type>::type
eval_type0;
- BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested,
(detail::make<eval_type0>() ++))
- typedef typename mpl::if_c<
- 1==sizeof(detail::check_reference((detail::make<eval_type0>()
++)))
- , typename nested::type &
- , typename nested::type
- >::type type;
- static type call(typename detail::as_param<eval_type0>::type a0)
+ // Handle post-decrement specially.
+ template<typename This, typename A0>
+ struct result<This(proto::tag::post_dec, A0 &)>
{
- return a0 --;
- }
- };
+ typedef typename proto::result_of::eval<A0,
derived_type>::type eval_type0;
+ BOOST_PROTO_DECLTYPE_NESTED_TYPEDEF_TPL(nested,
(detail::make<eval_type0>() ++))
+ typedef typename nested::type type;
+ static type call(typename detail::as_param<eval_type0>::type
a0)
+ {
+ return a0 --;
+ }
+ };
- // Handle subscript specially.
- template<typename This, typename A0, typename A1>
- struct result<This(proto::tag::subscript, A0 &, A1 &)>
- {
- typedef typename proto::result_of::eval<A0, derived_type>::type
eval_type0;
- typedef typename proto::result_of::eval<A1, derived_type>::type
eval_type1;
- BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested,
(detail::make<eval_type0>() [ detail::make<eval_type1>() ] ))
- typedef typename mpl::if_c<
- 1==sizeof(detail::check_reference((detail::make<eval_type0>()
[ detail::make<eval_type1>() ] )))
- , typename nested::type &
- , typename nested::type
- >::type type;
- static type call(typename detail::as_param<eval_type0>::type a0,
typename detail::as_param<eval_type1>::type a1)
+ // Handle subscript specially.
+ template<typename This, typename A0, typename A1>
+ struct result<This(proto::tag::subscript, A0 &, A1 &)>
{
- return a0 [ a1 ];
+ typedef typename proto::result_of::eval<A0,
derived_type>::type eval_type0;
+ typedef typename proto::result_of::eval<A1,
derived_type>::type eval_type1;
+ BOOST_PROTO_DECLTYPE_NESTED_TYPEDEF_TPL(nested,
(detail::make<eval_type0>() [ detail::make<eval_type1>() ] ))
+ typedef typename nested::type type;
+ static type call(typename detail::as_param<eval_type0>::type
a0, typename detail::as_param<eval_type1>::type a1)
+ {
+ return a0 [ a1 ];
+ }
+ };
+
+ template<typename A0>
+ A0 &
+ operator()(proto::tag::terminal, A0 &a0)
+ {
+ return a0;
}
- };
- // MSVC can't seem to handle typeof and function calls in templates
- #if !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1400))
- #define BOOST_PROTO_ARG(z, n, data)\
- typedef\
- typename proto::result_of::eval<BOOST_PP_CAT(A, n),
derived_type>::type\
- BOOST_PP_CAT(eval_type, n);\
- /**/
+ #define BOOST_PROTO_ARG(z, n, data)\
+ typedef\
+ typename proto::result_of::eval<BOOST_PP_CAT(A, n),
derived_type>::type\
+ BOOST_PP_CAT(eval_type, n);\
+ /**/
- #define BOOST_PP_LOCAL_MACRO(N)\
- template<typename This BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>\
- struct result<This(proto::tag::function
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, A, & BOOST_PP_INTERCEPT))>\
- {\
- BOOST_PP_REPEAT(N, BOOST_PROTO_ARG, ~)\
- BOOST_TYPEOF_NESTED_TYPEDEF_TPL(\
- nested\
- , (detail::make<eval_type0>() (\
- BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS(N,
detail::make<eval_type, >() BOOST_PP_INTERCEPT)\
- ))\
- )\
- typedef typename mpl::if_c<\
- 1==sizeof(detail::check_reference((detail::make<eval_type0>()
(\
- BOOST_PP_ENUM_SHIFTED_BINARY_PARAMS(N,
detail::make<eval_type, >() BOOST_PP_INTERCEPT)\
- ))))\
- , typename nested::type &\
- , typename nested::type\
- >::type type;\
- static type call(\
- BOOST_PP_ENUM_BINARY_PARAMS(N, typename
detail::as_param<eval_type, >::type a)\
- )\
- {\
- return a0 ( BOOST_PP_ENUM_SHIFTED_PARAMS(N, a) );\
- }\
- };\
- /**/
+ #define BOOST_PP_ITERATION_PARAMS_1 (3, (1, BOOST_PROTO_MAX_ARITY,
<boost/xpressive/proto/context.hpp>))
+ #include BOOST_PP_ITERATE()
+ #undef BOOST_PROTO_ARG
+
+ };
+
+ }}
- #define BOOST_PP_LOCAL_LIMITS (1, BOOST_PROTO_MAX_ARITY)
- #include BOOST_PP_LOCAL_ITERATE()
- #undef BOOST_PROTO_ARG
#endif
- template<typename A0>
- A0 &
- operator()(proto::tag::terminal, A0 &a0)
- {
- return a0;
- }
+#else
- #define BOOST_PP_LOCAL_MACRO(N)\
- template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>\
- typename result<derived_type(Tag
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, A, & BOOST_PP_INTERCEPT))>::type\
- operator()(Tag BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, A, & a))\
- {\
- return result<derived_type(Tag, BOOST_PP_ENUM_BINARY_PARAMS(N, A,
& BOOST_PP_INTERCEPT))>::call(\
- BOOST_PP_ENUM_BINARY_PARAMS(N, a, .eval(this->cast())
BOOST_PP_INTERCEPT)\
- );\
- }\
- /**/
+ #define N BOOST_PP_ITERATION()
- #define BOOST_PP_LOCAL_LIMITS (1, BOOST_PROTO_MAX_ARITY)
- #include BOOST_PP_LOCAL_ITERATE()
+ template<typename This BOOST_PP_ENUM_TRAILING_PARAMS(N, typename
A)>
+ struct result<This(proto::tag::function
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, A, & BOOST_PP_INTERCEPT))>
+ {
+ BOOST_PP_REPEAT(N, BOOST_PROTO_ARG, ~)
+ typedef typename detail::result_of_fixup<eval_type0>::type
function_type;
+ typedef typename boost::result_of<function_type(
BOOST_PP_ENUM_SHIFTED_PARAMS(N, eval_type) )>::type type;
+ static type call(
+ BOOST_PP_ENUM_BINARY_PARAMS(N, typename
detail::as_param<eval_type, >::type a)
+ )
+ {
+ return a0 ( BOOST_PP_ENUM_SHIFTED_PARAMS(N, a) );
+ }
+ };
- };
+ template<typename Tag BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
+ typename result<derived_type(Tag
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, A, & BOOST_PP_INTERCEPT))>::type
+ operator()(Tag BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, A, & a))
+ {
+ return result<derived_type(Tag, BOOST_PP_ENUM_BINARY_PARAMS(N,
A, & BOOST_PP_INTERCEPT))>::call(
+ BOOST_PP_ENUM_BINARY_PARAMS(N, a, .eval(this->cast())
BOOST_PP_INTERCEPT)
+ );
+ }
-}}
+ #undef N
#endif
Index: expr.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/expr.hpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- expr.hpp 3 Feb 2007 00:14:33 -0000 1.19
+++ expr.hpp 3 Feb 2007 09:04:30 -0000 1.20
@@ -127,18 +127,18 @@
}
template<typename A>
- expr<tag::assign, args2<ref<expr>, typename
result_of::as_arg<A>::type> > const
+ expr<tag::assign, args2<ref<expr>, typename result_of::as_arg<A
const>::type> > const
operator =(A const &a) const
{
- expr<tag::assign, args2<ref<expr>, typename
result_of::as_arg<A>::type> > that = {{*this}, proto::as_arg(a)};
+ expr<tag::assign, args2<ref<expr>, typename
result_of::as_arg<A const>::type> > that = {{*this}, proto::as_arg(a)};
return that;
}
template<typename A>
- expr<tag::subscript, args2<ref<expr>, typename
result_of::as_arg<A>::type> > const
+ expr<tag::subscript, args2<ref<expr>, typename result_of::as_arg<A
const>::type> > const
operator [](A const &a) const
{
- expr<tag::subscript, args2<ref<expr>, typename
result_of::as_arg<A>::type> > that = {{*this}, proto::as_arg(a)};
+ expr<tag::subscript, args2<ref<expr>, typename
result_of::as_arg<A const>::type> > that = {{*this}, proto::as_arg(a)};
return that;
}
@@ -168,14 +168,14 @@
template<typename This BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>
struct result<This(BOOST_PP_ENUM_PARAMS(N, A))>
- : result_of::BOOST_PP_CAT(funop, N)<expr
BOOST_PP_ENUM_TRAILING_PARAMS(N, A)>
+ : result_of::BOOST_PP_CAT(funop, N)<expr
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, typename remove_reference<A, >::type
BOOST_PP_INTERCEPT)>
{};
template<BOOST_PP_ENUM_PARAMS(N, typename A)>
- typename result_of::BOOST_PP_CAT(funop, N)<expr
BOOST_PP_ENUM_TRAILING_PARAMS(N, A)>::type const
+ typename result_of::BOOST_PP_CAT(funop, N)<expr
BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)>::type const
operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const &a)) const
{
- return result_of::BOOST_PP_CAT(funop, N)<expr
BOOST_PP_ENUM_TRAILING_PARAMS(N, A)>
+ return result_of::BOOST_PP_CAT(funop, N)<expr
BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)>
::call(*this BOOST_PP_ENUM_TRAILING_PARAMS(N, a));
}
Index: extends.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/extends.hpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- extends.hpp 3 Feb 2007 00:14:33 -0000 1.17
+++ extends.hpp 3 Feb 2007 09:04:30 -0000 1.18
@@ -53,19 +53,19 @@
}
template<typename A>
- typename generate<Domain, expr<tag::assign, args2<ref<Derived>,
typename result_of::as_arg<A>::type> >, tag::assign>::type const
+ typename generate<Domain, expr<tag::assign, args2<ref<Derived>,
typename result_of::as_arg<A const>::type> >, tag::assign>::type const
operator =(A const &a) const
{
- expr<tag::assign, args2<ref<Derived>, typename
result_of::as_arg<A>::type> > that = {{this->derived()}, proto::as_arg(a)};
- return generate<Domain, expr<tag::assign, args2<ref<Derived>,
typename result_of::as_arg<A>::type> >, tag::assign>::make(that);
+ expr<tag::assign, args2<ref<Derived>, typename result_of::as_arg<A
const>::type> > that = {{this->derived()}, proto::as_arg(a)};
+ return generate<Domain, expr<tag::assign, args2<ref<Derived>,
typename result_of::as_arg<A const>::type> >, tag::assign>::make(that);
}
template<typename A>
- typename generate<Domain, expr<tag::subscript, args2<ref<Derived>,
typename result_of::as_arg<A>::type> >, tag::subscript>::type const
+ typename generate<Domain, expr<tag::subscript, args2<ref<Derived>,
typename result_of::as_arg<A const>::type> >, tag::subscript>::type const
operator [](A const &a) const
{
- expr<tag::subscript, args2<ref<Derived>, typename
result_of::as_arg<A>::type> > that = {{this->derived()}, proto::as_arg(a)};
- return generate<Domain, expr<tag::subscript, args2<ref<Derived>,
typename result_of::as_arg<A>::type> >, tag::subscript>::make(that);
+ expr<tag::subscript, args2<ref<Derived>, typename
result_of::as_arg<A const>::type> > that = {{this->derived()},
proto::as_arg(a)};
+ return generate<Domain, expr<tag::subscript, args2<ref<Derived>,
typename result_of::as_arg<A const>::type> >, tag::subscript>::make(that);
}
template<typename Sig>
@@ -84,28 +84,45 @@
return generate<Domain, expr<tag::function, args1<ref<Derived> >
>, tag::function>::make(that);
}
- #define BOOST_PROTO_AS_OP(z, n, data)\
- proto::as_arg(BOOST_PP_CAT(a,n))\
- /**/
-
#define BOOST_PP_LOCAL_MACRO(N) \
template<typename This BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)>\
struct result<This(BOOST_PP_ENUM_PARAMS(N, A))>\
- {\
- typedef typename generate<Domain, expr<tag::function,
BOOST_PP_CAT(args, BOOST_PP_INC(N))<ref<Derived>
BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, typename result_of::as_arg<A, >::type
BOOST_PP_INTERCEPT)> >, tag::function>::type type;\
- };\
+ : generate<\
+ Domain\
+ , typename result_of::BOOST_PP_CAT(funop, N)<\
+ Derived\
+ BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(\
+ N\
+ , typename remove_reference<A\
+ , >::type BOOST_PP_INTERCEPT\
+ )\
+ >::type\
+ , tag::function\
+ >\
+ {};\
template<BOOST_PP_ENUM_PARAMS(N, typename A)>\
- typename generate<Domain, expr<tag::function, BOOST_PP_CAT(args,
BOOST_PP_INC(N))<ref<Derived> BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, typename
result_of::as_arg<A, >::type BOOST_PP_INTERCEPT)> > >::type const\
+ typename generate<\
+ Domain\
+ , typename result_of::BOOST_PP_CAT(funop, N)<\
+ Derived\
+ BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)\
+ >::type\
+ , tag::function\
+ >::type const\
operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const &a)) const\
{\
- expr<tag::function, BOOST_PP_CAT(args,
BOOST_PP_INC(N))<ref<Derived> BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, typename
result_of::as_arg<A, >::type BOOST_PP_INTERCEPT)> > that = {{this->derived()}
BOOST_PP_ENUM_TRAILING(N, BOOST_PROTO_AS_OP, _)};\
- return generate<Domain, expr<tag::function, BOOST_PP_CAT(args,
BOOST_PP_INC(N))<ref<Derived> BOOST_PP_ENUM_TRAILING_BINARY_PARAMS(N, typename
result_of::as_arg<A, >::type BOOST_PP_INTERCEPT)> >,
tag::function>::make(that);\
+ typedef result_of::BOOST_PP_CAT(funop, N)<\
+ Derived\
+ BOOST_PP_ENUM_TRAILING_PARAMS(N, const A)\
+ > funop;\
+ return generate<Domain, typename funop::type,
tag::function>::make(\
+ funop::call(this->derived() BOOST_PP_ENUM_TRAILING_PARAMS(N,
a))\
+ );\
}\
/**/
#define BOOST_PP_LOCAL_LIMITS (1, BOOST_PP_DEC(BOOST_PROTO_MAX_ARITY))
#include BOOST_PP_LOCAL_ITERATE()
- #undef BOOST_PROTO_AS_OP
};
}}
Index: make_expr.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/make_expr.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- make_expr.hpp 3 Feb 2007 00:14:33 -0000 1.9
+++ make_expr.hpp 3 Feb 2007 09:04:30 -0000 1.10
@@ -42,7 +42,7 @@
struct make_expr_impl;
#define BOOST_PROTO_AS_EXPR(z, n, data) proto::as_expr(BOOST_PP_CAT(a,
n))
- #define BOOST_PROTO_VALUE_AT(z, n, data) typename
fusion::result_of::value_at_c< Sequence, n >::type
+ #define BOOST_PROTO_VALUE_AT(z, n, data) typename
fusion::result_of::value_at_c< Sequence, n >::type
#define BOOST_PROTO_AT(z, n, data) fusion::at_c< n >(data)
#define BOOST_PP_ITERATION_PARAMS_1 (4, (1, BOOST_PROTO_MAX_ARITY,
<boost/xpressive/proto/make_expr.hpp>, 1))
#include BOOST_PP_ITERATE()
@@ -93,8 +93,6 @@
template<BOOST_PP_ENUM_PARAMS(N, typename A)>
struct result_
{
- BOOST_STATIC_ASSERT(!is_reference<A0>::value);
-
typedef expr<Tag, BOOST_PP_CAT(args, N)<
BOOST_PP_ENUM_BINARY_PARAMS(N, typename
result_of::as_expr<A, >::type BOOST_PP_INTERCEPT)
> > type;
@@ -105,11 +103,11 @@
template<typename This BOOST_PP_ENUM_TRAILING_PARAMS(N,
typename A)>
struct result<This(BOOST_PP_ENUM_PARAMS(N, A))>
- : result_<BOOST_PP_ENUM_BINARY_PARAMS(N, typename
detail::remove_cv_ref<A, >::type BOOST_PP_INTERCEPT)>
+ : result_<BOOST_PP_ENUM_BINARY_PARAMS(N, typename
remove_reference<A, >::type BOOST_PP_INTERCEPT)>
{};
template<BOOST_PP_ENUM_PARAMS(N, typename A)>
- typename result_<BOOST_PP_ENUM_PARAMS(N, A)>::type
+ typename result_<BOOST_PP_ENUM_PARAMS(N, const A)>::type
operator ()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const &a)) const
{
typename result_<BOOST_PP_ENUM_PARAMS(N, A)>::type that =
Index: traits.hpp
===================================================================
RCS file: /cvsroot/boost/boost/boost/xpressive/proto/traits.hpp,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- traits.hpp 3 Feb 2007 00:50:38 -0000 1.38
+++ traits.hpp 3 Feb 2007 09:04:30 -0000 1.39
@@ -28,6 +28,8 @@
#include <boost/mpl/bool.hpp>
#include <boost/static_assert.hpp>
#include <boost/utility/result_of.hpp>
+ #include <boost/type_traits/is_array.hpp>
+ #include <boost/type_traits/is_function.hpp>
#include <boost/xpressive/proto/proto_fwd.hpp>
#include <boost/xpressive/proto/ref.hpp>
#include <boost/xpressive/proto/args.hpp>
@@ -66,42 +68,27 @@
template<typename T, typename EnableIf>
struct as_expr
{
- typedef expr<proto::tag::terminal, args1<T> > type;
-
- private:
- friend struct op::as_expr;
- typedef type result_type;
- static result_type call(T const &t)
- {
- type that = {t};
- return that;
- }
- };
-
- template<typename T, std::size_t N>
- struct as_expr<T [N], void>
- {
- typedef expr<proto::tag::terminal, args1<T (&)[N]> > type;
+ typedef typename mpl::if_<mpl::or_<is_function<T>, is_array<T>
>, T &, T>::type arg0_type;
+ typedef expr<proto::tag::terminal, args1<arg0_type> > type;
private:
friend struct op::as_expr;
typedef type result_type;
- static result_type call(T (&t)[N])
+ static result_type call(T &t)
{
- type that = {t};
- return that;
+ return type::make(t);
}
};
template<typename T>
struct as_expr<T, typename T::is_boost_proto_expr_>
{
- typedef T type;
+ typedef typename T::boost_proto_expr_type_ type;
private:
friend struct op::as_expr;
- typedef T const &result_type;
- static result_type call(T const &t)
+ typedef type const &result_type;
+ static result_type call(T &t)
{
return t;
}
@@ -111,13 +98,13 @@
template<typename T, typename EnableIf>
struct as_arg
{
- typedef expr<proto::tag::terminal, args1<T const &> > type;
+ typedef expr<proto::tag::terminal, args1<T &> > type;
};
template<typename T>
struct as_arg<T, typename T::is_boost_proto_expr_>
{
- typedef ref<T> type;
+ typedef ref<typename T::boost_proto_expr_type_> type;
};
template<typename Expr, typename N>
@@ -294,25 +281,19 @@
template<typename This, typename T>
struct result<This(T)>
- : result_of::as_expr<typename detail::remove_cv_ref<T>::type>
+ : result_of::as_expr<typename remove_reference<T>::type>
{};
- template<typename T, std::size_t N>
- typename result_of::as_expr<T[N]>::result_type operator()(T
(&t)[N]) const
- {
- return result_of::as_expr<T[N]>::call(t);
- }
-
- template<typename T, std::size_t N>
- typename result_of::as_expr<T const[N]>::result_type
operator()(T const (&t)[N]) const
+ template<typename T>
+ typename result_of::as_expr<T>::result_type operator()(T &t)
const
{
- return result_of::as_expr<T const[N]>::call(t);
+ return result_of::as_expr<T>::call(t);
}
template<typename T>
- typename result_of::as_expr<T>::result_type operator()(T const
&t) const
+ typename result_of::as_expr<T const>::result_type operator()(T
const &t) const
{
- return result_of::as_expr<T>::call(t);
+ return result_of::as_expr<T const>::call(t);
}
};
@@ -323,7 +304,7 @@
template<typename This, typename T>
struct result<This(T)>
- : result_of::as_arg<typename detail::remove_cv_ref<T>::type>
+ : result_of::as_arg<typename remove_reference<T>::type>
{};
template<typename T>
@@ -334,11 +315,19 @@
template<typename T>
typename result_of::as_arg<T>::type
- operator()(T const &t) const
+ operator()(T &t) const
{
typename result_of::as_arg<T>::type that = {t};
return that;
}
+
+ template<typename T>
+ typename result_of::as_arg<T const>::type
+ operator()(T const &t) const
+ {
+ typename result_of::as_arg<T const>::type that = {t};
+ return that;
+ }
};
template<long N>
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Boost-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/boost-cvs