diff options
author | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
---|---|---|
committer | Chanho Park <chanho61.park@samsung.com> | 2014-12-11 18:55:56 +0900 |
commit | 08c1e93fa36a49f49325a07fe91ff92c964c2b6c (patch) | |
tree | 7a7053ceb8874b28ec4b868d4c49b500008a102e /boost/proto | |
parent | bb4dd8289b351fae6b55e303f189127a394a1edd (diff) | |
download | boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.gz boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.tar.bz2 boost-08c1e93fa36a49f49325a07fe91ff92c964c2b6c.zip |
Imported Upstream version 1.57.0upstream/1.57.0
Diffstat (limited to 'boost/proto')
64 files changed, 2034 insertions, 859 deletions
diff --git a/boost/proto/args.hpp b/boost/proto/args.hpp index 330096f267..9b7afdb447 100644 --- a/boost/proto/args.hpp +++ b/boost/proto/args.hpp @@ -16,52 +16,19 @@ #include <boost/preprocessor/repetition/enum_params.hpp> #include <boost/preprocessor/repetition/repeat.hpp> #include <boost/preprocessor/repetition/repeat_from_to.hpp> -#include <boost/type_traits/is_function.hpp> -#include <boost/type_traits/is_abstract.hpp> #include <boost/mpl/if.hpp> -#include <boost/mpl/or.hpp> #include <boost/mpl/void.hpp> #include <boost/proto/proto_fwd.hpp> +#include <boost/proto/detail/is_noncopyable.hpp> + +#include <boost/mpl/or.hpp> +#include <boost/type_traits/is_function.hpp> +#include <boost/type_traits/is_abstract.hpp> namespace boost { namespace proto { namespace detail { - // All classes derived from std::ios_base have these public nested types, - // and are non-copyable. This is an imperfect test, but it's the best we - // we can do. - template<typename T> - yes_type check_is_iostream( - typename T::failure * - , typename T::Init * - , typename T::fmtflags * - , typename T::iostate * - , typename T::openmode * - , typename T::seekdir * - ); - - template<typename T> - no_type check_is_iostream(...); - - template<typename T> - struct is_iostream - { - static bool const value = sizeof(yes_type) == sizeof(check_is_iostream<T>(0,0,0,0,0,0)); - typedef mpl::bool_<value> type; - }; - - /// INTERNAL ONLY - // This should be a customization point. And it serves the same purpose - // as the is_noncopyable trait in Boost.Foreach. - template<typename T> - struct ref_only - : mpl::or_< - is_function<T> - , is_abstract<T> - , is_iostream<T> - > - {}; - /// INTERNAL ONLY template<typename Expr> struct expr_traits @@ -102,7 +69,7 @@ namespace boost { namespace proto template<typename T> struct term_traits<T &> { - typedef typename mpl::if_c<ref_only<T>::value, T &, T>::type value_type; + typedef typename mpl::if_c<is_noncopyable<T>::value, T &, T>::type value_type; typedef T &reference; typedef T &const_reference; }; diff --git a/boost/proto/context/default.hpp b/boost/proto/context/default.hpp index 6aeb596289..f3e586f0e8 100644 --- a/boost/proto/context/default.hpp +++ b/boost/proto/context/default.hpp @@ -364,7 +364,7 @@ namespace boost { namespace proto result_type invoke(Expr &expr, Context &context, mpl::true_, mpl::false_) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (BOOST_PROTO_DEFAULT_EVAL(~, 1, expr))) ->* BOOST_PROTO_DEFAULT_EVAL(~, 0, expr) @@ -374,7 +374,7 @@ namespace boost { namespace proto result_type invoke(Expr &expr, Context &context, mpl::false_, mpl::true_) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (BOOST_PROTO_DEFAULT_EVAL(~, 1, expr))) ->* BOOST_PROTO_DEFAULT_EVAL(~, 0, expr) diff --git a/boost/proto/context/detail/default_eval.hpp b/boost/proto/context/detail/default_eval.hpp index 4114f92943..980427604e 100644 --- a/boost/proto/context/detail/default_eval.hpp +++ b/boost/proto/context/detail/default_eval.hpp @@ -69,7 +69,7 @@ result_type invoke(Expr &expr, Context &context, mpl::true_) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (BOOST_PROTO_DEFAULT_EVAL(~, 1, expr))) ->* BOOST_PROTO_DEFAULT_EVAL(~, 0, expr) diff --git a/boost/proto/context/detail/preprocessed/default_eval.hpp b/boost/proto/context/detail/preprocessed/default_eval.hpp index 4efde73d5d..ebc69ce062 100644 --- a/boost/proto/context/detail/preprocessed/default_eval.hpp +++ b/boost/proto/context/detail/preprocessed/default_eval.hpp @@ -32,7 +32,7 @@ result_type invoke(Expr &expr, Context &context, mpl::true_) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (proto::eval(proto::child_c< 1>( expr), context))) ->* proto::eval(proto::child_c< 0>( expr), context) @@ -66,7 +66,7 @@ result_type invoke(Expr &expr, Context &context, mpl::true_) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (proto::eval(proto::child_c< 1>( expr), context))) ->* proto::eval(proto::child_c< 0>( expr), context) @@ -100,7 +100,7 @@ result_type invoke(Expr &expr, Context &context, mpl::true_) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (proto::eval(proto::child_c< 1>( expr), context))) ->* proto::eval(proto::child_c< 0>( expr), context) @@ -134,7 +134,7 @@ result_type invoke(Expr &expr, Context &context, mpl::true_) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (proto::eval(proto::child_c< 1>( expr), context))) ->* proto::eval(proto::child_c< 0>( expr), context) @@ -168,7 +168,7 @@ result_type invoke(Expr &expr, Context &context, mpl::true_) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (proto::eval(proto::child_c< 1>( expr), context))) ->* proto::eval(proto::child_c< 0>( expr), context) @@ -202,7 +202,7 @@ result_type invoke(Expr &expr, Context &context, mpl::true_) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (proto::eval(proto::child_c< 1>( expr), context))) ->* proto::eval(proto::child_c< 0>( expr), context) @@ -236,7 +236,7 @@ result_type invoke(Expr &expr, Context &context, mpl::true_) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (proto::eval(proto::child_c< 1>( expr), context))) ->* proto::eval(proto::child_c< 0>( expr), context) @@ -270,7 +270,7 @@ result_type invoke(Expr &expr, Context &context, mpl::true_) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (proto::eval(proto::child_c< 1>( expr), context))) ->* proto::eval(proto::child_c< 0>( expr), context) diff --git a/boost/proto/detail/any.hpp b/boost/proto/detail/any.hpp new file mode 100644 index 0000000000..ae47b1c57c --- /dev/null +++ b/boost/proto/detail/any.hpp @@ -0,0 +1,85 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file any.hpp +/// Contains definition the detail::any type +// +// Copyright 2012 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_DETAIL_ANY_HPP_EAN_18_07_2012 +#define BOOST_PROTO_DETAIL_ANY_HPP_EAN_18_07_2012 + +#include <boost/preprocessor/facilities/intercept.hpp> +#include <boost/preprocessor/repetition/repeat.hpp> +#include <boost/preprocessor/repetition/enum_params.hpp> +#include <boost/proto/proto_fwd.hpp> + +namespace boost { namespace proto +{ + namespace detail + { + namespace anyns + { + //////////////////////////////////////////////////////////////////////////////////////////// + struct any + { + template<typename T> any(T const &) {} + any operator=(any); + any operator[](any); + #define M0(Z, N, DATA) any operator()(BOOST_PP_ENUM_PARAMS_Z(Z, N, any BOOST_PP_INTERCEPT)); + BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, M0, ~) + #undef M0 + + template<typename T> + operator T &() const volatile; + + any operator+(); + any operator-(); + any operator*(); + any operator&(); + any operator~(); + any operator!(); + any operator++(); + any operator--(); + any operator++(int); + any operator--(int); + + friend any operator<<(any, any); + friend any operator>>(any, any); + friend any operator*(any, any); + friend any operator/(any, any); + friend any operator%(any, any); + friend any operator+(any, any); + friend any operator-(any, any); + friend any operator<(any, any); + friend any operator>(any, any); + friend any operator<=(any, any); + friend any operator>=(any, any); + friend any operator==(any, any); + friend any operator!=(any, any); + friend any operator||(any, any); + friend any operator&&(any, any); + friend any operator&(any, any); + friend any operator|(any, any); + friend any operator^(any, any); + friend any operator,(any, any); + friend any operator->*(any, any); + + friend any operator<<=(any, any); + friend any operator>>=(any, any); + friend any operator*=(any, any); + friend any operator/=(any, any); + friend any operator%=(any, any); + friend any operator+=(any, any); + friend any operator-=(any, any); + friend any operator&=(any, any); + friend any operator|=(any, any); + friend any operator^=(any, any); + }; + } + + using anyns::any; + } +}} + +#endif diff --git a/boost/proto/detail/as_expr.hpp b/boost/proto/detail/as_expr.hpp index fb46576b89..b7e5c30c05 100644 --- a/boost/proto/detail/as_expr.hpp +++ b/boost/proto/detail/as_expr.hpp @@ -17,7 +17,7 @@ #include <boost/proto/proto_fwd.hpp> #include <boost/proto/args.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif @@ -180,7 +180,7 @@ namespace boost { namespace proto { namespace detail }}} -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/detail/as_lvalue.hpp b/boost/proto/detail/as_lvalue.hpp index 8ff9091b28..df4dacbe78 100644 --- a/boost/proto/detail/as_lvalue.hpp +++ b/boost/proto/detail/as_lvalue.hpp @@ -11,7 +11,7 @@ #include <boost/proto/proto_fwd.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif @@ -36,7 +36,7 @@ namespace boost { namespace proto } }} -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/detail/basic_expr.hpp b/boost/proto/detail/basic_expr.hpp index 8c679925d7..51c4d955fd 100644 --- a/boost/proto/detail/basic_expr.hpp +++ b/boost/proto/detail/basic_expr.hpp @@ -100,7 +100,7 @@ typedef basic_expr proto_grammar; typedef basic_default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef basic_expr proto_derived_expr; typedef void proto_is_expr_; /**< INTERNAL ONLY */ diff --git a/boost/proto/detail/classtypeof.hpp b/boost/proto/detail/class_member_traits.hpp index a3228cd4b5..98d8ebbf48 100644 --- a/boost/proto/detail/classtypeof.hpp +++ b/boost/proto/detail/class_member_traits.hpp @@ -1,16 +1,16 @@ #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) - #include <boost/proto/detail/preprocessed/classtypeof.hpp> + #include <boost/proto/detail/preprocessed/class_member_traits.hpp> #elif !defined(BOOST_PP_IS_ITERATING) #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) - #pragma wave option(preserve: 2, line: 0, output: "preprocessed/classtypeof.hpp") + #pragma wave option(preserve: 2, line: 0, output: "preprocessed/class_member_traits.hpp") #endif /////////////////////////////////////////////////////////////////////////////// - // classtypeof.hpp - // Contains specializations of the classtypeof\<\> class template. + // class_member_traits.hpp + // Contains specializations of the class_member_traits\<\> class template. // // Copyright 2008 Eric Niebler. Distributed under the Boost // Software License, Version 1.0. (See accompanying file @@ -21,7 +21,7 @@ #endif #define BOOST_PP_ITERATION_PARAMS_1 \ - (3, (0, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/classtypeof.hpp>)) + (3, (0, BOOST_PROTO_MAX_ARITY, <boost/proto/detail/class_member_traits.hpp>)) #include BOOST_PP_ITERATE() #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) @@ -33,15 +33,17 @@ #define N BOOST_PP_ITERATION() template<typename T, typename U BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)> - struct classtypeof<T (U::*)(BOOST_PP_ENUM_PARAMS(N, A))> + struct class_member_traits<T (U::*)(BOOST_PP_ENUM_PARAMS(N, A))> { - typedef U type; + typedef U class_type; + typedef T result_type; }; template<typename T, typename U BOOST_PP_ENUM_TRAILING_PARAMS(N, typename A)> - struct classtypeof<T (U::*)(BOOST_PP_ENUM_PARAMS(N, A)) const> + struct class_member_traits<T (U::*)(BOOST_PP_ENUM_PARAMS(N, A)) const> { - typedef U type; + typedef U class_type; + typedef T result_type; }; #undef N diff --git a/boost/proto/detail/decltype.hpp b/boost/proto/detail/decltype.hpp index 92679ab274..58820713b0 100644 --- a/boost/proto/detail/decltype.hpp +++ b/boost/proto/detail/decltype.hpp @@ -33,14 +33,18 @@ #include <boost/utility/addressof.hpp> #include <boost/utility/result_of.hpp> #include <boost/utility/enable_if.hpp> +#include <boost/proto/proto_fwd.hpp> +#include <boost/proto/detail/any.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif -#ifndef BOOST_NO_DECLTYPE -# define BOOST_PROTO_DECLTYPE_(EXPR, TYPE) typedef decltype(EXPR) TYPE; +// We're STILL using Boost.Typeof on MSVC even for msvc-11.0 because of this bug: +// https://connect.microsoft.com/VisualStudio/feedback/details/765392/decltype-of-a-pointer-to-member-operator-gets-ref-qualification-wrong +#if !defined(BOOST_NO_CXX11_DECLTYPE) && !BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1700)) +# define BOOST_PROTO_DECLTYPE_(EXPR, TYPE) typedef decltype((EXPR)) TYPE; #else # define BOOST_PROTO_DECLTYPE_NESTED_TYPEDEF_TPL_(NESTED, EXPR) \ BOOST_TYPEOF_NESTED_TYPEDEF_TPL(BOOST_PP_CAT(nested_and_hidden_, NESTED), EXPR) \ @@ -61,68 +65,6 @@ namespace boost { namespace proto { namespace detail { - namespace anyns - { - //////////////////////////////////////////////////////////////////////////////////////////// - struct any - { - any(...); - any operator=(any); - any operator[](any); - #define M0(Z, N, DATA) any operator()(BOOST_PP_ENUM_PARAMS_Z(Z, N, any BOOST_PP_INTERCEPT)); - BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, M0, ~) - #undef M0 - - template<typename T> - operator T &() const volatile; - - any operator+(); - any operator-(); - any operator*(); - any operator&(); - any operator~(); - any operator!(); - any operator++(); - any operator--(); - any operator++(int); - any operator--(int); - - friend any operator<<(any, any); - friend any operator>>(any, any); - friend any operator*(any, any); - friend any operator/(any, any); - friend any operator%(any, any); - friend any operator+(any, any); - friend any operator-(any, any); - friend any operator<(any, any); - friend any operator>(any, any); - friend any operator<=(any, any); - friend any operator>=(any, any); - friend any operator==(any, any); - friend any operator!=(any, any); - friend any operator||(any, any); - friend any operator&&(any, any); - friend any operator&(any, any); - friend any operator|(any, any); - friend any operator^(any, any); - friend any operator,(any, any); - friend any operator->*(any, any); - - friend any operator<<=(any, any); - friend any operator>>=(any, any); - friend any operator*=(any, any); - friend any operator/=(any, any); - friend any operator%=(any, any); - friend any operator+=(any, any); - friend any operator-=(any, any); - friend any operator&=(any, any); - friend any operator|=(any, any); - friend any operator^=(any, any); - }; - } - - using anyns::any; - //////////////////////////////////////////////////////////////////////////////////////////// template<typename T> struct as_mutable @@ -242,16 +184,17 @@ namespace boost { namespace proto //////////////////////////////////////////////////////////////////////////////////////////// template<typename T> - struct classtypeof; + struct class_member_traits; template<typename T, typename U> - struct classtypeof<T U::*> + struct class_member_traits<T U::*> { - typedef U type; + typedef U class_type; + typedef T result_type; }; // Other specializations are generated by the preprocessor - #include <boost/proto/detail/classtypeof.hpp> + #include <boost/proto/detail/class_member_traits.hpp> //////////////////////////////////////////////////////////////////////////////////////////// template<typename T> @@ -382,9 +325,9 @@ namespace boost { namespace proto struct mem_ptr_fun<T, U, true> { typedef - typename classtypeof< + typename class_member_traits< typename uncvref<U>::type - >::type + >::class_type V; BOOST_PROTO_DECLTYPE_( @@ -478,10 +421,10 @@ namespace boost { namespace proto struct memfun { typedef typename uncvref<PMF>::type pmf_type; - typedef typename classtypeof<pmf_type>::type V; - typedef typename BOOST_PROTO_RESULT_OF<pmf_type(T)>::type result_type; + typedef typename class_member_traits<pmf_type>::class_type V; + typedef typename class_member_traits<pmf_type>::result_type result_type; - memfun(T t, PMF p) + memfun(T t, pmf_type p) : obj(t) , pmf(p) {} @@ -497,13 +440,13 @@ namespace boost { namespace proto private: T obj; - PMF pmf; + pmf_type pmf; }; } // namespace detail }} -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/detail/deduce_domain.hpp b/boost/proto/detail/deduce_domain.hpp index 630304f842..0d4f3a59dc 100644 --- a/boost/proto/detail/deduce_domain.hpp +++ b/boost/proto/detail/deduce_domain.hpp @@ -44,7 +44,7 @@ namespace boost { typedef Domain type; typedef domain_<typename Domain::proto_super_domain> base; - #ifdef BOOST_NO_DECLTYPE + #ifdef BOOST_NO_CXX11_DECLTYPE using base::deduce98; static int const index = base::index + 1; static typename sized_type<index>::type deduce98(domain_<Domain>*); @@ -58,7 +58,7 @@ namespace boost struct domain_<not_a_domain> { typedef not_a_domain type; - #ifdef BOOST_NO_DECLTYPE + #ifdef BOOST_NO_CXX11_DECLTYPE static int const index = 1; static sized_type<1>::type deduce98(void*); #else @@ -86,7 +86,7 @@ namespace boost sized_type<4>::type default_test(domain_<default_domain>*, domain_<basic_default_domain>*); sized_type<4>::type default_test(domain_<basic_default_domain>*, domain_<basic_default_domain>*); - #ifdef BOOST_NO_DECLTYPE + #ifdef BOOST_NO_CXX11_DECLTYPE template<int N, typename Domain> struct nth_domain : nth_domain<N - 1, typename Domain::base> @@ -116,7 +116,7 @@ namespace boost > struct common_domain2 { - #ifdef BOOST_NO_DECLTYPE + #ifdef BOOST_NO_CXX11_DECLTYPE static int const index = domain_<D0>::index - sizeof(domain_<D0>::deduce98((domain_<D1>*)0)); typedef typename nth_domain<index, domain_<D0> >::type type; #else diff --git a/boost/proto/detail/dont_care.hpp b/boost/proto/detail/dont_care.hpp index 262340e2b4..578af7cacb 100644 --- a/boost/proto/detail/dont_care.hpp +++ b/boost/proto/detail/dont_care.hpp @@ -11,7 +11,7 @@ #include <boost/config.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif @@ -27,7 +27,7 @@ namespace boost { namespace proto } }} -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/detail/expr.hpp b/boost/proto/detail/expr.hpp index 318a02d8ec..8ceedd8956 100644 --- a/boost/proto/detail/expr.hpp +++ b/boost/proto/detail/expr.hpp @@ -1,6 +1,6 @@ #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) - #ifndef BOOST_NO_VARIADIC_TEMPLATES + #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES #include <boost/proto/detail/preprocessed/expr_variadic.hpp> #else #include <boost/proto/detail/preprocessed/expr.hpp> @@ -51,7 +51,7 @@ // Generate non-variadic versions of expr #if defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES) - #define BOOST_NO_VARIADIC_TEMPLATES + #define BOOST_NO_CXX11_VARIADIC_TEMPLATES #pragma wave option(preserve: 2, line: 0, output: "preprocessed/expr.hpp") /////////////////////////////////////////////////////////////////////////////// @@ -74,7 +74,7 @@ #include BOOST_PP_ITERATE() #pragma wave option(output: null) - #undef BOOST_NO_VARIADIC_TEMPLATES + #undef BOOST_NO_CXX11_VARIADIC_TEMPLATES #endif #undef BOOST_PROTO_CHILD @@ -131,7 +131,7 @@ typedef basic_expr<Tag, proto_args, BOOST_PP_ITERATION() > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; /**< INTERNAL ONLY */ @@ -398,7 +398,7 @@ typedef typename result_of::funop<Sig, expr, default_domain>::type const type; }; - #ifndef BOOST_NO_VARIADIC_TEMPLATES + #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES /// \overload /// template<typename ...A> @@ -437,7 +437,7 @@ } #endif - #else // BOOST_NO_VARIADIC_TEMPLATES + #else // BOOST_NO_CXX11_VARIADIC_TEMPLATES /// Function call /// diff --git a/boost/proto/detail/extends_funop.hpp b/boost/proto/detail/extends_funop.hpp index bb157c587e..d722641303 100644 --- a/boost/proto/detail/extends_funop.hpp +++ b/boost/proto/detail/extends_funop.hpp @@ -1,6 +1,6 @@ #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) - #ifndef BOOST_NO_VARIADIC_TEMPLATES + #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES BOOST_PROTO_EXTENDS_FUNCTION_() BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(BOOST_PP_EMPTY) BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(BOOST_PROTO_CONST) diff --git a/boost/proto/detail/extends_funop_const.hpp b/boost/proto/detail/extends_funop_const.hpp index 229a0f932f..1791a1b2f1 100644 --- a/boost/proto/detail/extends_funop_const.hpp +++ b/boost/proto/detail/extends_funop_const.hpp @@ -1,6 +1,6 @@ #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) - #ifndef BOOST_NO_VARIADIC_TEMPLATES + #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES BOOST_PROTO_EXTENDS_FUNCTION_() BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(BOOST_PROTO_CONST) #else diff --git a/boost/proto/detail/ignore_unused.hpp b/boost/proto/detail/ignore_unused.hpp index 6004b83d98..7ca344636a 100644 --- a/boost/proto/detail/ignore_unused.hpp +++ b/boost/proto/detail/ignore_unused.hpp @@ -12,7 +12,7 @@ #include <boost/config.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif @@ -27,7 +27,7 @@ namespace boost { namespace proto } }} -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/detail/is_noncopyable.hpp b/boost/proto/detail/is_noncopyable.hpp new file mode 100644 index 0000000000..3e2da7836f --- /dev/null +++ b/boost/proto/detail/is_noncopyable.hpp @@ -0,0 +1,65 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file is_noncopyable.hpp +/// Utility for detecting when types are non-copyable +// +// Copyright 2008 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_DETAIL_IS_NONCOPYABLE_HPP_EAN_19_07_2012 +#define BOOST_PROTO_DETAIL_IS_NONCOPYABLE_HPP_EAN_19_07_2012 + +#include <boost/noncopyable.hpp> +#include <boost/mpl/or.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/type_traits/is_base_of.hpp> +#include <boost/type_traits/is_abstract.hpp> +#include <boost/type_traits/is_function.hpp> +#include <boost/proto/proto_fwd.hpp> + +namespace boost { namespace proto { namespace detail +{ + // All classes derived from std::ios_base have these public nested types, + // and are non-copyable. This is an imperfect test, but it's the best we + // we can do. + template<typename T> + yes_type check_is_iostream( + typename T::failure * + , typename T::Init * + , typename T::fmtflags * + , typename T::iostate * + , typename T::openmode * + , typename T::seekdir * + ); + + template<typename T> + no_type check_is_iostream(...); + + template<typename T> + struct is_iostream + { + static bool const value = sizeof(yes_type) == sizeof(check_is_iostream<T>(0,0,0,0,0,0)); + typedef mpl::bool_<value> type; + }; + + /// INTERNAL ONLY + // This should be a customization point. And it serves the same purpose + // as the is_noncopyable trait in Boost.Foreach. + template<typename T> + struct is_noncopyable + : mpl::or_< + is_function<T> + , is_abstract<T> + , is_iostream<T> + , is_base_of<noncopyable, T> + > + {}; + + template<typename T, std::size_t N> + struct is_noncopyable<T[N]> + : mpl::true_ + {}; + +}}} + +#endif diff --git a/boost/proto/detail/poly_function.hpp b/boost/proto/detail/poly_function.hpp index 55a4dbf3c3..2bde53bda9 100644 --- a/boost/proto/detail/poly_function.hpp +++ b/boost/proto/detail/poly_function.hpp @@ -24,6 +24,7 @@ #include <boost/preprocessor/repetition/enum_trailing_params.hpp> #include <boost/preprocessor/repetition/enum_binary_params.hpp> #include <boost/proto/proto_fwd.hpp> +#include <boost/proto/detail/is_noncopyable.hpp> #ifdef _MSC_VER # pragma warning(push) @@ -37,21 +38,28 @@ namespace boost { namespace proto { namespace detail template<typename T> struct normalize_arg { - typedef T type; + typedef typename mpl::if_c<is_noncopyable<T>::value, T &, T>::type type; + typedef T &reference; + }; + + template<typename T> + struct normalize_arg<T const> + { + typedef typename mpl::if_c<is_noncopyable<T>::value, T const &, T>::type type; typedef T const &reference; }; template<typename T> struct normalize_arg<T &> { - typedef T type; - typedef T const &reference; + typedef typename mpl::if_c<is_noncopyable<T>::value, T &, T>::type type; + typedef T &reference; }; template<typename T> struct normalize_arg<T const &> { - typedef T type; + typedef typename mpl::if_c<is_noncopyable<T>::value, T const &, T>::type type; typedef T const &reference; }; @@ -63,6 +71,13 @@ namespace boost { namespace proto { namespace detail }; template<typename T> + struct normalize_arg<boost::reference_wrapper<T> const> + { + typedef T &type; + typedef T &reference; + }; + + template<typename T> struct normalize_arg<boost::reference_wrapper<T> &> { typedef T &type; @@ -93,7 +108,7 @@ namespace boost { namespace proto { namespace detail type operator()() const { - return *this; + return this->value; } private: @@ -117,7 +132,7 @@ namespace boost { namespace proto { namespace detail type operator()() const { - return *this; + return this->value; } private: @@ -137,8 +152,8 @@ namespace boost { namespace proto { namespace detail {}; //////////////////////////////////////////////////////////////////////////////////////////////// - #define BOOST_PROTO_POLY_FUNCTION() \ - typedef void is_poly_function_base_; \ + #define BOOST_PROTO_POLY_FUNCTION() \ + typedef void is_poly_function_base_; \ /**/ //////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/boost/proto/detail/pop_front.hpp b/boost/proto/detail/pop_front.hpp deleted file mode 100644 index 73c053997e..0000000000 --- a/boost/proto/detail/pop_front.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - Copyright (c) 2008 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_DETAIL_FUSION_POP_FRONT_EAH_01_22_2008 -#define BOOST_PROTO_DETAIL_FUSION_POP_FRONT_EAH_01_22_2008 - -#include <boost/spirit/fusion/sequence/range.hpp> -#include <boost/spirit/fusion/sequence/begin.hpp> -#include <boost/spirit/fusion/sequence/end.hpp> -#include <boost/spirit/fusion/iterator/next.hpp> - -namespace boost { namespace fusion -{ - namespace meta - { - template <typename Sequence> - struct pop_front - { - typedef - range< - typename next< - typename begin<Sequence>::type - >::type - , typename end<Sequence>::type - > - type; - }; - } - - template <typename Sequence> - inline typename meta::pop_front<Sequence const>::type - pop_front(Sequence const& seq) - { - typedef typename meta::pop_front<Sequence const>::type result; - return result(fusion::next(fusion::begin(seq)), fusion::end(seq)); - } -}} - -#endif diff --git a/boost/proto/detail/preprocessed/basic_expr.hpp b/boost/proto/detail/preprocessed/basic_expr.hpp index f679a86aa2..c28708fb5a 100644 --- a/boost/proto/detail/preprocessed/basic_expr.hpp +++ b/boost/proto/detail/preprocessed/basic_expr.hpp @@ -44,7 +44,7 @@ typedef basic_expr proto_grammar; typedef basic_default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef basic_expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; @@ -122,7 +122,7 @@ typedef basic_expr proto_grammar; typedef basic_default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef basic_expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; @@ -206,7 +206,7 @@ typedef basic_expr proto_grammar; typedef basic_default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef basic_expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; @@ -277,7 +277,7 @@ typedef basic_expr proto_grammar; typedef basic_default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef basic_expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; @@ -348,7 +348,7 @@ typedef basic_expr proto_grammar; typedef basic_default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef basic_expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; @@ -419,7 +419,7 @@ typedef basic_expr proto_grammar; typedef basic_default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef basic_expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; @@ -490,7 +490,7 @@ typedef basic_expr proto_grammar; typedef basic_default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef basic_expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; @@ -561,7 +561,7 @@ typedef basic_expr proto_grammar; typedef basic_default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef basic_expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; typedef Arg6 proto_child6; proto_child6 child6; @@ -632,7 +632,7 @@ typedef basic_expr proto_grammar; typedef basic_default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef basic_expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; typedef Arg6 proto_child6; proto_child6 child6; typedef Arg7 proto_child7; proto_child7 child7; @@ -703,7 +703,7 @@ typedef basic_expr proto_grammar; typedef basic_default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef basic_expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; typedef Arg6 proto_child6; proto_child6 child6; typedef Arg7 proto_child7; proto_child7 child7; typedef Arg8 proto_child8; proto_child8 child8; @@ -774,7 +774,7 @@ typedef basic_expr proto_grammar; typedef basic_default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef basic_expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; typedef Arg6 proto_child6; proto_child6 child6; typedef Arg7 proto_child7; proto_child7 child7; typedef Arg8 proto_child8; proto_child8 child8; typedef Arg9 proto_child9; proto_child9 child9; diff --git a/boost/proto/detail/preprocessed/class_member_traits.hpp b/boost/proto/detail/preprocessed/class_member_traits.hpp new file mode 100644 index 0000000000..418957a9c6 --- /dev/null +++ b/boost/proto/detail/preprocessed/class_member_traits.hpp @@ -0,0 +1,139 @@ + /////////////////////////////////////////////////////////////////////////////// + // class_member_traits.hpp + // Contains specializations of the class_member_traits\<\> class template. + // + // Copyright 2008 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) + template<typename T, typename U > + struct class_member_traits<T (U::*)()> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U > + struct class_member_traits<T (U::*)() const> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0> + struct class_member_traits<T (U::*)(A0)> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0> + struct class_member_traits<T (U::*)(A0) const> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1> + struct class_member_traits<T (U::*)(A0 , A1)> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1> + struct class_member_traits<T (U::*)(A0 , A1) const> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2> + struct class_member_traits<T (U::*)(A0 , A1 , A2)> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2> + struct class_member_traits<T (U::*)(A0 , A1 , A2) const> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3> + struct class_member_traits<T (U::*)(A0 , A1 , A2 , A3)> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3> + struct class_member_traits<T (U::*)(A0 , A1 , A2 , A3) const> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4> + struct class_member_traits<T (U::*)(A0 , A1 , A2 , A3 , A4)> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4> + struct class_member_traits<T (U::*)(A0 , A1 , A2 , A3 , A4) const> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5> + struct class_member_traits<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5)> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5> + struct class_member_traits<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5) const> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6> + struct class_member_traits<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6)> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6> + struct class_member_traits<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6) const> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7> + struct class_member_traits<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7)> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7> + struct class_member_traits<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7) const> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8> + struct class_member_traits<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8)> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8> + struct class_member_traits<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8) const> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9> + struct class_member_traits<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9)> + { + typedef U class_type; + typedef T result_type; + }; + template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9> + struct class_member_traits<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9) const> + { + typedef U class_type; + typedef T result_type; + }; diff --git a/boost/proto/detail/preprocessed/classtypeof.hpp b/boost/proto/detail/preprocessed/classtypeof.hpp deleted file mode 100644 index f8fce63e33..0000000000 --- a/boost/proto/detail/preprocessed/classtypeof.hpp +++ /dev/null @@ -1,117 +0,0 @@ - /////////////////////////////////////////////////////////////////////////////// - // classtypeof.hpp - // Contains specializations of the classtypeof\<\> class template. - // - // Copyright 2008 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) - template<typename T, typename U > - struct classtypeof<T (U::*)()> - { - typedef U type; - }; - template<typename T, typename U > - struct classtypeof<T (U::*)() const> - { - typedef U type; - }; - template<typename T, typename U , typename A0> - struct classtypeof<T (U::*)(A0)> - { - typedef U type; - }; - template<typename T, typename U , typename A0> - struct classtypeof<T (U::*)(A0) const> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1> - struct classtypeof<T (U::*)(A0 , A1)> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1> - struct classtypeof<T (U::*)(A0 , A1) const> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2> - struct classtypeof<T (U::*)(A0 , A1 , A2)> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2> - struct classtypeof<T (U::*)(A0 , A1 , A2) const> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3> - struct classtypeof<T (U::*)(A0 , A1 , A2 , A3)> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3> - struct classtypeof<T (U::*)(A0 , A1 , A2 , A3) const> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4> - struct classtypeof<T (U::*)(A0 , A1 , A2 , A3 , A4)> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4> - struct classtypeof<T (U::*)(A0 , A1 , A2 , A3 , A4) const> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5> - struct classtypeof<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5)> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5> - struct classtypeof<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5) const> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6> - struct classtypeof<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6)> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6> - struct classtypeof<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6) const> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7> - struct classtypeof<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7)> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7> - struct classtypeof<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7) const> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8> - struct classtypeof<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8)> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8> - struct classtypeof<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8) const> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9> - struct classtypeof<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9)> - { - typedef U type; - }; - template<typename T, typename U , typename A0 , typename A1 , typename A2 , typename A3 , typename A4 , typename A5 , typename A6 , typename A7 , typename A8 , typename A9> - struct classtypeof<T (U::*)(A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9) const> - { - typedef U type; - }; diff --git a/boost/proto/detail/preprocessed/expr.hpp b/boost/proto/detail/preprocessed/expr.hpp index 92714ceec8..645bb5ae6a 100644 --- a/boost/proto/detail/preprocessed/expr.hpp +++ b/boost/proto/detail/preprocessed/expr.hpp @@ -44,7 +44,7 @@ typedef basic_expr<Tag, proto_args, 0 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; @@ -585,7 +585,7 @@ typedef basic_expr<Tag, proto_args, 1 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; @@ -916,7 +916,7 @@ typedef basic_expr<Tag, proto_args, 2 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; @@ -1234,7 +1234,7 @@ typedef basic_expr<Tag, proto_args, 3 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; @@ -1552,7 +1552,7 @@ typedef basic_expr<Tag, proto_args, 4 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; @@ -1870,7 +1870,7 @@ typedef basic_expr<Tag, proto_args, 5 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; @@ -2188,7 +2188,7 @@ typedef basic_expr<Tag, proto_args, 6 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; @@ -2506,7 +2506,7 @@ typedef basic_expr<Tag, proto_args, 7 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; typedef Arg6 proto_child6; proto_child6 child6; @@ -2824,7 +2824,7 @@ typedef basic_expr<Tag, proto_args, 8 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; typedef Arg6 proto_child6; proto_child6 child6; typedef Arg7 proto_child7; proto_child7 child7; @@ -3142,7 +3142,7 @@ typedef basic_expr<Tag, proto_args, 9 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; typedef Arg6 proto_child6; proto_child6 child6; typedef Arg7 proto_child7; proto_child7 child7; typedef Arg8 proto_child8; proto_child8 child8; @@ -3460,7 +3460,7 @@ typedef basic_expr<Tag, proto_args, 10 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; typedef Arg6 proto_child6; proto_child6 child6; typedef Arg7 proto_child7; proto_child7 child7; typedef Arg8 proto_child8; proto_child8 child8; typedef Arg9 proto_child9; proto_child9 child9; diff --git a/boost/proto/detail/preprocessed/expr_variadic.hpp b/boost/proto/detail/preprocessed/expr_variadic.hpp index 2d07a772e7..2ab633b309 100644 --- a/boost/proto/detail/preprocessed/expr_variadic.hpp +++ b/boost/proto/detail/preprocessed/expr_variadic.hpp @@ -44,7 +44,7 @@ typedef basic_expr<Tag, proto_args, 0 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; @@ -330,7 +330,7 @@ typedef basic_expr<Tag, proto_args, 1 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; @@ -533,7 +533,7 @@ typedef basic_expr<Tag, proto_args, 2 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; @@ -723,7 +723,7 @@ typedef basic_expr<Tag, proto_args, 3 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; @@ -913,7 +913,7 @@ typedef basic_expr<Tag, proto_args, 4 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; @@ -1103,7 +1103,7 @@ typedef basic_expr<Tag, proto_args, 5 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; @@ -1293,7 +1293,7 @@ typedef basic_expr<Tag, proto_args, 6 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; @@ -1483,7 +1483,7 @@ typedef basic_expr<Tag, proto_args, 7 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; typedef Arg6 proto_child6; proto_child6 child6; @@ -1673,7 +1673,7 @@ typedef basic_expr<Tag, proto_args, 8 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; typedef Arg6 proto_child6; proto_child6 child6; typedef Arg7 proto_child7; proto_child7 child7; @@ -1863,7 +1863,7 @@ typedef basic_expr<Tag, proto_args, 9 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; typedef Arg6 proto_child6; proto_child6 child6; typedef Arg7 proto_child7; proto_child7 child7; typedef Arg8 proto_child8; proto_child8 child8; @@ -2053,7 +2053,7 @@ typedef basic_expr<Tag, proto_args, 10 > proto_grammar; typedef default_domain proto_domain; typedef default_generator proto_generator; - typedef proto::tag::proto_expr fusion_tag; + typedef proto::tag::proto_expr<Tag, proto_domain> fusion_tag; typedef expr proto_derived_expr; typedef void proto_is_expr_; typedef Arg0 proto_child0; proto_child0 child0; typedef Arg1 proto_child1; proto_child1 child1; typedef Arg2 proto_child2; proto_child2 child2; typedef Arg3 proto_child3; proto_child3 child3; typedef Arg4 proto_child4; proto_child4 child4; typedef Arg5 proto_child5; proto_child5 child5; typedef Arg6 proto_child6; proto_child6 child6; typedef Arg7 proto_child7; proto_child7 child7; typedef Arg8 proto_child8; proto_child8 child8; typedef Arg9 proto_child9; proto_child9 child9; diff --git a/boost/proto/detail/preprocessed/traits.hpp b/boost/proto/detail/preprocessed/traits.hpp index faf013b9e5..abbb5a79eb 100644 --- a/boost/proto/detail/preprocessed/traits.hpp +++ b/boost/proto/detail/preprocessed/traits.hpp @@ -95,7 +95,7 @@ typedef proto::basic_expr<proto::tag::function, list1<A0>, 1> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<function, Expr, State, Data> + : detail::pass_through_impl<function, deduce_domain, Expr, State, Data> {}; typedef proto::tag::function proto_tag; @@ -130,7 +130,7 @@ typedef proto::basic_expr<Tag, list1<A0>, 1> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<nary_expr, Expr, State, Data> + : detail::pass_through_impl<nary_expr, deduce_domain, Expr, State, Data> {}; typedef Tag proto_tag; @@ -237,7 +237,7 @@ typedef proto::basic_expr<proto::tag::function, list2<A0 , A1>, 2> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<function, Expr, State, Data> + : detail::pass_through_impl<function, deduce_domain, Expr, State, Data> {}; typedef proto::tag::function proto_tag; @@ -272,7 +272,7 @@ typedef proto::basic_expr<Tag, list2<A0 , A1>, 2> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<nary_expr, Expr, State, Data> + : detail::pass_through_impl<nary_expr, deduce_domain, Expr, State, Data> {}; typedef Tag proto_tag; @@ -379,7 +379,7 @@ typedef proto::basic_expr<proto::tag::function, list3<A0 , A1 , A2>, 3> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<function, Expr, State, Data> + : detail::pass_through_impl<function, deduce_domain, Expr, State, Data> {}; typedef proto::tag::function proto_tag; @@ -414,7 +414,7 @@ typedef proto::basic_expr<Tag, list3<A0 , A1 , A2>, 3> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<nary_expr, Expr, State, Data> + : detail::pass_through_impl<nary_expr, deduce_domain, Expr, State, Data> {}; typedef Tag proto_tag; @@ -521,7 +521,7 @@ typedef proto::basic_expr<proto::tag::function, list4<A0 , A1 , A2 , A3>, 4> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<function, Expr, State, Data> + : detail::pass_through_impl<function, deduce_domain, Expr, State, Data> {}; typedef proto::tag::function proto_tag; @@ -556,7 +556,7 @@ typedef proto::basic_expr<Tag, list4<A0 , A1 , A2 , A3>, 4> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<nary_expr, Expr, State, Data> + : detail::pass_through_impl<nary_expr, deduce_domain, Expr, State, Data> {}; typedef Tag proto_tag; @@ -663,7 +663,7 @@ typedef proto::basic_expr<proto::tag::function, list5<A0 , A1 , A2 , A3 , A4>, 5> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<function, Expr, State, Data> + : detail::pass_through_impl<function, deduce_domain, Expr, State, Data> {}; typedef proto::tag::function proto_tag; @@ -698,7 +698,7 @@ typedef proto::basic_expr<Tag, list5<A0 , A1 , A2 , A3 , A4>, 5> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<nary_expr, Expr, State, Data> + : detail::pass_through_impl<nary_expr, deduce_domain, Expr, State, Data> {}; typedef Tag proto_tag; @@ -805,7 +805,7 @@ typedef proto::basic_expr<proto::tag::function, list6<A0 , A1 , A2 , A3 , A4 , A5>, 6> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<function, Expr, State, Data> + : detail::pass_through_impl<function, deduce_domain, Expr, State, Data> {}; typedef proto::tag::function proto_tag; @@ -840,7 +840,7 @@ typedef proto::basic_expr<Tag, list6<A0 , A1 , A2 , A3 , A4 , A5>, 6> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<nary_expr, Expr, State, Data> + : detail::pass_through_impl<nary_expr, deduce_domain, Expr, State, Data> {}; typedef Tag proto_tag; @@ -947,7 +947,7 @@ typedef proto::basic_expr<proto::tag::function, list7<A0 , A1 , A2 , A3 , A4 , A5 , A6>, 7> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<function, Expr, State, Data> + : detail::pass_through_impl<function, deduce_domain, Expr, State, Data> {}; typedef proto::tag::function proto_tag; @@ -982,7 +982,7 @@ typedef proto::basic_expr<Tag, list7<A0 , A1 , A2 , A3 , A4 , A5 , A6>, 7> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<nary_expr, Expr, State, Data> + : detail::pass_through_impl<nary_expr, deduce_domain, Expr, State, Data> {}; typedef Tag proto_tag; @@ -1089,7 +1089,7 @@ typedef proto::basic_expr<proto::tag::function, list8<A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7>, 8> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<function, Expr, State, Data> + : detail::pass_through_impl<function, deduce_domain, Expr, State, Data> {}; typedef proto::tag::function proto_tag; @@ -1124,7 +1124,7 @@ typedef proto::basic_expr<Tag, list8<A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7>, 8> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<nary_expr, Expr, State, Data> + : detail::pass_through_impl<nary_expr, deduce_domain, Expr, State, Data> {}; typedef Tag proto_tag; @@ -1231,7 +1231,7 @@ typedef proto::basic_expr<proto::tag::function, list9<A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8>, 9> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<function, Expr, State, Data> + : detail::pass_through_impl<function, deduce_domain, Expr, State, Data> {}; typedef proto::tag::function proto_tag; @@ -1266,7 +1266,7 @@ typedef proto::basic_expr<Tag, list9<A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8>, 9> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<nary_expr, Expr, State, Data> + : detail::pass_through_impl<nary_expr, deduce_domain, Expr, State, Data> {}; typedef Tag proto_tag; @@ -1369,7 +1369,7 @@ typedef proto::basic_expr<proto::tag::function, list10<A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9>, 10> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<function, Expr, State, Data> + : detail::pass_through_impl<function, deduce_domain, Expr, State, Data> {}; typedef proto::tag::function proto_tag; @@ -1399,7 +1399,7 @@ typedef proto::basic_expr<Tag, list10<A0 , A1 , A2 , A3 , A4 , A5 , A6 , A7 , A8 , A9>, 10> proto_grammar; template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<nary_expr, Expr, State, Data> + : detail::pass_through_impl<nary_expr, deduce_domain, Expr, State, Data> {}; typedef Tag proto_tag; diff --git a/boost/proto/detail/reverse.hpp b/boost/proto/detail/reverse.hpp deleted file mode 100644 index 64ac6ba4a3..0000000000 --- a/boost/proto/detail/reverse.hpp +++ /dev/null @@ -1,189 +0,0 @@ -/*============================================================================= - Copyright (c) 2001-2006 Joel de Guzman - Copyright (c) 2008 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_DETAIL_FUSION_REVERSE_EAH_01_22_2008 -#define BOOST_PROTO_DETAIL_FUSION_REVERSE_EAH_01_22_2008 - -#include <boost/spirit/fusion/detail/access.hpp> -#include <boost/spirit/fusion/iterator/as_fusion_iterator.hpp> -#include <boost/spirit/fusion/iterator/detail/iterator_base.hpp> -#include <boost/spirit/fusion/sequence/detail/sequence_base.hpp> -#include <boost/spirit/fusion/iterator/next.hpp> -#include <boost/spirit/fusion/iterator/prior.hpp> -#include <boost/spirit/fusion/iterator/deref.hpp> -#include <boost/spirit/fusion/iterator/value_of.hpp> -#include <boost/spirit/fusion/sequence/begin.hpp> -#include <boost/spirit/fusion/sequence/end.hpp> - -namespace boost { namespace fusion -{ - struct reverse_view_tag; - struct reverse_view_iterator_tag; - - template <typename First> - struct reverse_view_iterator - : iterator_base<reverse_view_iterator<First> > - { - typedef as_fusion_iterator<First> converter; - typedef typename converter::type first_type; - typedef reverse_view_iterator_tag tag; - - reverse_view_iterator(First const& first) - : first(converter::convert(first)) {} - - first_type first; - }; - - template <typename Sequence> - struct reverse_view : sequence_base<reverse_view<Sequence> > - { - typedef as_fusion_sequence<Sequence> seq_converter; - typedef typename seq_converter::type seq; - - typedef reverse_view_tag tag; - typedef typename meta::begin<seq>::type first_type; - typedef typename meta::end<seq>::type last_type; - - reverse_view(Sequence& seq) - : first(fusion::begin(seq)) - , last(fusion::end(seq)) - {} - - first_type first; - last_type last; - }; - - namespace meta - { - template <> - struct deref_impl<reverse_view_iterator_tag> - { - template <typename Iterator> - struct apply - { - typedef typename - meta::deref< - typename meta::prior< - typename Iterator::first_type - >::type - >::type - type; - - static type - call(Iterator const& i) - { - return *fusion::prior(i.first); - } - }; - }; - - template <> - struct prior_impl<reverse_view_iterator_tag> - { - template <typename Iterator> - struct apply - { - typedef typename Iterator::first_type first_type; - typedef typename next_impl<typename first_type::tag>:: - template apply<first_type> - wrapped; - - typedef reverse_view_iterator<typename wrapped::type> type; - - static type - call(Iterator const& i) - { - return type(wrapped::call(i.first)); - } - }; - }; - - template <> - struct next_impl<reverse_view_iterator_tag> - { - template <typename Iterator> - struct apply - { - typedef typename Iterator::first_type first_type; - typedef typename prior_impl<typename first_type::tag>:: - template apply<first_type> - wrapped; - - typedef reverse_view_iterator<typename wrapped::type> type; - - static type - call(Iterator const& i) - { - return type(wrapped::call(i.first)); - } - }; - }; - - template <> - struct value_impl<reverse_view_iterator_tag> - { - template <typename Iterator> - struct apply - { - typedef typename - meta::value_of< - typename meta::prior< - typename Iterator::first_type - >::type - >::type - type; - }; - }; - - template <> - struct begin_impl<reverse_view_tag> - { - template <typename Sequence> - struct apply - { - typedef reverse_view_iterator<typename Sequence::last_type> type; - - static type - call(Sequence const& s) - { - return type(s.last); - } - }; - }; - - template <> - struct end_impl<reverse_view_tag> - { - template <typename Sequence> - struct apply - { - typedef reverse_view_iterator<typename Sequence::first_type> type; - - static type - call(Sequence const& s) - { - return type(s.first); - } - }; - }; - - template <typename Sequence> - struct reverse - { - typedef reverse_view<Sequence> type; - }; - } - - template <typename Sequence> - inline reverse_view<Sequence const> - reverse(Sequence const& view) - { - return reverse_view<Sequence const>(view); - } -}} - -#endif diff --git a/boost/proto/detail/static_const.hpp b/boost/proto/detail/static_const.hpp new file mode 100644 index 0000000000..0dfdbc6672 --- /dev/null +++ b/boost/proto/detail/static_const.hpp @@ -0,0 +1,27 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file static_const.hpp +/// Contains definition of static_const for declaring static constants that +// +// Copyright 2008 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_DETAIL_STATIC_CONST_HPP_EAN_20_07_2012 +#define BOOST_PROTO_DETAIL_STATIC_CONST_HPP_EAN_20_07_2012 + +namespace boost { namespace proto +{ + namespace detail + { + template<typename T> + struct static_const + { + static T const value; + }; + + template<typename T> + T const static_const<T>::value = {}; + } +}} + +#endif diff --git a/boost/proto/detail/traits.hpp b/boost/proto/detail/traits.hpp index 1b5abab88d..d4fd2bce1b 100644 --- a/boost/proto/detail/traits.hpp +++ b/boost/proto/detail/traits.hpp @@ -65,7 +65,7 @@ template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<function, Expr, State, Data> + : detail::pass_through_impl<function, deduce_domain, Expr, State, Data> {}; /// INTERNAL ONLY @@ -110,7 +110,7 @@ template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<nary_expr, Expr, State, Data> + : detail::pass_through_impl<nary_expr, deduce_domain, Expr, State, Data> {}; /// INTERNAL ONLY diff --git a/boost/proto/domain.hpp b/boost/proto/domain.hpp index 44bc45d36b..33dabeba49 100644 --- a/boost/proto/domain.hpp +++ b/boost/proto/domain.hpp @@ -18,7 +18,7 @@ #include <boost/proto/detail/as_expr.hpp> #include <boost/proto/detail/deduce_domain.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif @@ -330,7 +330,7 @@ namespace boost { namespace proto }} -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/expr.hpp b/boost/proto/expr.hpp index cb8a28f6e9..1bd64985d8 100644 --- a/boost/proto/expr.hpp +++ b/boost/proto/expr.hpp @@ -26,7 +26,7 @@ #include <boost/proto/args.hpp> #include <boost/proto/traits.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4510) // default constructor could not be generated # pragma warning(disable : 4512) // assignment operator could not be generated @@ -90,6 +90,19 @@ namespace boost { namespace proto return that; } + // Work-around for: + // https://connect.microsoft.com/VisualStudio/feedback/details/765449/codegen-stack-corruption-using-runtime-checks-when-aggregate-initializing-struct + #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1700)) + template<typename T, typename Expr, typename C, typename U> + BOOST_FORCEINLINE + Expr make_terminal(T &t, Expr *, proto::term<U C::*> *) + { + Expr that; + that.child0 = t; + return that; + } + #endif + template<typename T, typename U> struct same_cv { @@ -143,7 +156,7 @@ namespace boost { namespace proto }} -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/extends.hpp b/boost/proto/extends.hpp index 3a8151964c..1fb0429050 100644 --- a/boost/proto/extends.hpp +++ b/boost/proto/extends.hpp @@ -34,7 +34,7 @@ #include <boost/proto/generate.hpp> #include <boost/proto/detail/remove_typename.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif @@ -172,7 +172,7 @@ namespace boost { namespace proto typedef typename proto_base_expr::address_of_hack_type_ proto_address_of_hack_type_; \ typedef void proto_is_expr_; /**< INTERNAL ONLY */ \ static const long proto_arity_c = proto_base_expr::proto_arity_c; \ - typedef boost::proto::tag::proto_expr fusion_tag; \ + typedef boost::proto::tag::proto_expr<proto_tag, proto_domain> fusion_tag; \ BOOST_PP_REPEAT(BOOST_PROTO_MAX_ARITY, BOOST_PROTO_EXTENDS_CHILD, ~) \ \ BOOST_PROTO_DISABLE_MSVC_C4714 BOOST_FORCEINLINE \ @@ -393,7 +393,7 @@ namespace boost { namespace proto }; \ /**/ - #ifndef BOOST_NO_VARIADIC_TEMPLATES + #ifndef BOOST_NO_CXX11_VARIADIC_TEMPLATES #define BOOST_PROTO_EXTENDS_FUNCTION_CONST() \ BOOST_PROTO_EXTENDS_FUNCTION_() \ BOOST_PROTO_DEFINE_FUN_OP_VARIADIC_IMPL_(BOOST_PROTO_CONST) \ @@ -571,7 +571,7 @@ namespace boost { namespace proto typedef detail::not_a_valid_type proto_address_of_hack_type_; typedef void proto_is_expr_; /**< INTERNAL ONLY */ static const long proto_arity_c = 2; - typedef boost::proto::tag::proto_expr fusion_tag; + typedef boost::proto::tag::proto_expr<proto_tag, Domain> fusion_tag; typedef This &proto_child0; typedef expr<tag::terminal, term<Fun> > const &proto_child1; typedef expr<proto_tag, proto_args, proto_arity_c> proto_base_expr; @@ -640,7 +640,7 @@ namespace boost { namespace proto }} -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/functional.hpp b/boost/proto/functional.hpp index e3c868c4f8..a8577d730b 100644 --- a/boost/proto/functional.hpp +++ b/boost/proto/functional.hpp @@ -11,5 +11,6 @@ #include <boost/proto/functional/std.hpp> #include <boost/proto/functional/fusion.hpp> +#include <boost/proto/functional/range.hpp> #endif diff --git a/boost/proto/functional/range.hpp b/boost/proto/functional/range.hpp new file mode 100644 index 0000000000..e83c853266 --- /dev/null +++ b/boost/proto/functional/range.hpp @@ -0,0 +1,19 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file range.hpp +/// Proto callables for things found in the boost range library +// +// Copyright 2012 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_FUNCTIONAL_RANGE_HPP_EAN_27_08_2012 +#define BOOST_PROTO_FUNCTIONAL_RANGE_HPP_EAN_27_08_2012 + +#include <boost/proto/functional/range/begin.hpp> +#include <boost/proto/functional/range/empty.hpp> +#include <boost/proto/functional/range/end.hpp> +#include <boost/proto/functional/range/rbegin.hpp> +#include <boost/proto/functional/range/rend.hpp> +#include <boost/proto/functional/range/size.hpp> + +#endif diff --git a/boost/proto/functional/range/begin.hpp b/boost/proto/functional/range/begin.hpp new file mode 100644 index 0000000000..c425a4164f --- /dev/null +++ b/boost/proto/functional/range/begin.hpp @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file begin.hpp +/// Proto callables for boost::begin() +// +// Copyright 2012 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_FUNCTIONAL_RANGE_BEGIN_HPP_EAN_27_08_2012 +#define BOOST_PROTO_FUNCTIONAL_RANGE_BEGIN_HPP_EAN_27_08_2012 + +#include <boost/range/begin.hpp> +#include <boost/proto/proto_fwd.hpp> + +namespace boost { namespace proto { namespace functional +{ + + // A PolymorphicFunctionObject that wraps boost::begin() + struct begin + { + BOOST_PROTO_CALLABLE() + + template<typename Sig> + struct result; + + template<typename This, typename Rng> + struct result<This(Rng)> + : boost::range_iterator<Rng const> + {}; + + template<typename This, typename Rng> + struct result<This(Rng &)> + : boost::range_iterator<Rng> + {}; + + template<typename Rng> + typename boost::range_iterator<Rng>::type operator()(Rng &rng) const + { + return boost::begin(rng); + } + + template<typename Rng> + typename boost::range_iterator<Rng const>::type operator()(Rng const &rng) const + { + return boost::begin(rng); + } + }; + +}}} + +#endif diff --git a/boost/proto/functional/range/empty.hpp b/boost/proto/functional/range/empty.hpp new file mode 100644 index 0000000000..debb82dcac --- /dev/null +++ b/boost/proto/functional/range/empty.hpp @@ -0,0 +1,34 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file empty.hpp +/// Proto callables for boost::empty() +// +// Copyright 2012 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_FUNCTIONAL_RANGE_EMPTY_HPP_EAN_27_08_2012 +#define BOOST_PROTO_FUNCTIONAL_RANGE_EMPTY_HPP_EAN_27_08_2012 + +#include <boost/range/empty.hpp> +#include <boost/proto/proto_fwd.hpp> + +namespace boost { namespace proto { namespace functional +{ + + // A PolymorphicFunctionObject that wraps boost::empty() + struct empty + { + BOOST_PROTO_CALLABLE() + + typedef bool result_type; + + template<typename Rng> + bool operator()(Rng const &rng) const + { + return boost::empty(rng); + } + }; + +}}} + +#endif diff --git a/boost/proto/functional/range/end.hpp b/boost/proto/functional/range/end.hpp new file mode 100644 index 0000000000..f7506fd89f --- /dev/null +++ b/boost/proto/functional/range/end.hpp @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file end.hpp +/// Proto callables for boost::end() +// +// Copyright 2012 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_FUNCTIONAL_RANGE_END_HPP_EAN_27_08_2012 +#define BOOST_PROTO_FUNCTIONAL_RANGE_END_HPP_EAN_27_08_2012 + +#include <boost/range/end.hpp> +#include <boost/proto/proto_fwd.hpp> + +namespace boost { namespace proto { namespace functional +{ + + // A PolymorphicFunctionObject that wraps boost::end() + struct end + { + BOOST_PROTO_CALLABLE() + + template<typename Sig> + struct result; + + template<typename This, typename Rng> + struct result<This(Rng)> + : boost::range_iterator<Rng const> + {}; + + template<typename This, typename Rng> + struct result<This(Rng &)> + : boost::range_iterator<Rng> + {}; + + template<typename Rng> + typename boost::range_iterator<Rng>::type operator()(Rng &rng) const + { + return boost::end(rng); + } + + template<typename Rng> + typename boost::range_iterator<Rng const>::type operator()(Rng const &rng) const + { + return boost::end(rng); + } + }; + +}}} + +#endif diff --git a/boost/proto/functional/range/rbegin.hpp b/boost/proto/functional/range/rbegin.hpp new file mode 100644 index 0000000000..ecb7db94ea --- /dev/null +++ b/boost/proto/functional/range/rbegin.hpp @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file rbegin.hpp +/// Proto callables for boost::rbegin() +// +// Copyright 2012 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_FUNCTIONAL_RANGE_RBEGIN_HPP_EAN_27_08_2012 +#define BOOST_PROTO_FUNCTIONAL_RANGE_RBEGIN_HPP_EAN_27_08_2012 + +#include <boost/range/rbegin.hpp> +#include <boost/proto/proto_fwd.hpp> + +namespace boost { namespace proto { namespace functional +{ + + // A PolymorphicFunctionObject that wraps boost::rbegin() + struct rbegin + { + BOOST_PROTO_CALLABLE() + + template<typename Sig> + struct result; + + template<typename This, typename Rng> + struct result<This(Rng)> + : boost::range_reverse_iterator<Rng const> + {}; + + template<typename This, typename Rng> + struct result<This(Rng &)> + : boost::range_reverse_iterator<Rng> + {}; + + template<typename Rng> + typename boost::range_reverse_iterator<Rng>::type operator()(Rng &rng) const + { + return boost::rbegin(rng); + } + + template<typename Rng> + typename boost::range_reverse_iterator<Rng const>::type operator()(Rng const &rng) const + { + return boost::rbegin(rng); + } + }; + +}}} + +#endif diff --git a/boost/proto/functional/range/rend.hpp b/boost/proto/functional/range/rend.hpp new file mode 100644 index 0000000000..5b3778209d --- /dev/null +++ b/boost/proto/functional/range/rend.hpp @@ -0,0 +1,51 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file rend.hpp +/// Proto callables for boost::rend() +// +// Copyright 2012 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_FUNCTIONAL_RANGE_REND_HPP_EAN_27_08_2012 +#define BOOST_PROTO_FUNCTIONAL_RANGE_REND_HPP_EAN_27_08_2012 + +#include <boost/range/rend.hpp> +#include <boost/proto/proto_fwd.hpp> + +namespace boost { namespace proto { namespace functional +{ + + // A PolymorphicFunctionObject that wraps boost::rend() + struct rend + { + BOOST_PROTO_CALLABLE() + + template<typename Sig> + struct result; + + template<typename This, typename Rng> + struct result<This(Rng)> + : boost::range_reverse_iterator<Rng const> + {}; + + template<typename This, typename Rng> + struct result<This(Rng &)> + : boost::range_reverse_iterator<Rng> + {}; + + template<typename Rng> + typename boost::range_reverse_iterator<Rng>::type operator()(Rng &rng) const + { + return boost::rend(rng); + } + + template<typename Rng> + typename boost::range_reverse_iterator<Rng const>::type operator()(Rng const &rng) const + { + return boost::rend(rng); + } + }; + +}}} + +#endif diff --git a/boost/proto/functional/range/size.hpp b/boost/proto/functional/range/size.hpp new file mode 100644 index 0000000000..3fcdda1159 --- /dev/null +++ b/boost/proto/functional/range/size.hpp @@ -0,0 +1,45 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file size.hpp +/// Proto callables for boost::size() +// +// Copyright 2012 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_FUNCTIONAL_RANGE_SIZE_HPP_EAN_27_08_2012 +#define BOOST_PROTO_FUNCTIONAL_RANGE_SIZE_HPP_EAN_27_08_2012 + +#include <boost/range/size.hpp> +#include <boost/proto/proto_fwd.hpp> + +namespace boost { namespace proto { namespace functional +{ + + // A PolymorphicFunctionObject that wraps boost::size() + struct size + { + BOOST_PROTO_CALLABLE() + + template<typename Sig> + struct result; + + template<typename This, typename Rng> + struct result<This(Rng)> + : boost::range_size<Rng> + {}; + + template<typename This, typename Rng> + struct result<This(Rng &)> + : boost::range_size<Rng> + {}; + + template<typename Rng> + typename boost::range_size<Rng>::type operator()(Rng const &rng) const + { + return boost::size(rng); + } + }; + +}}} + +#endif diff --git a/boost/proto/functional/std.hpp b/boost/proto/functional/std.hpp index 2f997ef78a..38758601c2 100644 --- a/boost/proto/functional/std.hpp +++ b/boost/proto/functional/std.hpp @@ -10,5 +10,6 @@ #define BOOST_PROTO_FUNCTIONAL_STD_HPP_EAN_11_27_2010 #include <boost/proto/functional/std/utility.hpp> +#include <boost/proto/functional/std/iterator.hpp> #endif diff --git a/boost/proto/functional/std/iterator.hpp b/boost/proto/functional/std/iterator.hpp new file mode 100644 index 0000000000..3ee2c25011 --- /dev/null +++ b/boost/proto/functional/std/iterator.hpp @@ -0,0 +1,158 @@ +/////////////////////////////////////////////////////////////////////////////// +/// \file iterator.hpp +/// Proto callables for std functions found in \<iterator\> +// +// Copyright 2012 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_FUNCTIONAL_STD_ITERATOR_HPP_EAN_27_08_2012 +#define BOOST_PROTO_FUNCTIONAL_STD_ITERATOR_HPP_EAN_27_08_2012 + +#include <iterator> +#include <boost/type_traits/remove_const.hpp> +#include <boost/type_traits/remove_reference.hpp> +#include <boost/proto/proto_fwd.hpp> + +namespace boost { namespace proto { namespace functional +{ + + // A PolymorphicFunctionObject wrapping std::advance + struct advance + { + BOOST_PROTO_CALLABLE() + + typedef void result_type; + + template<typename InputIterator, typename Distance> + void operator()(InputIterator &x, Distance n) const + { + std::advance(x, n); + } + }; + + // A PolymorphicFunctionObject wrapping std::distance + struct distance + { + BOOST_PROTO_CALLABLE() + + template<typename Sig> + struct result; + + template<typename This, typename InputIter1, typename InputIter2> + struct result<This(InputIter1, InputIter2)> + { + typedef + typename std::iterator_traits< + typename boost::remove_const< + typename boost::remove_reference<InputIter1>::type + >::type + >::difference_type + type; + }; + + template<typename InputIterator> + typename std::iterator_traits<InputIterator>::difference_type + operator()(InputIterator first, InputIterator last) const + { + return std::distance(first, last); + } + }; + + // A PolymorphicFunctionObject wrapping std::next + struct next + { + BOOST_PROTO_CALLABLE() + + template<typename Sig> + struct result; + + template<typename This, typename ForwardIterator> + struct result<This(ForwardIterator)> + { + typedef + typename boost::remove_const< + typename boost::remove_reference<ForwardIterator>::type + >::type + type; + }; + + template<typename This, typename ForwardIterator, typename Distance> + struct result<This(ForwardIterator, Distance)> + { + typedef + typename boost::remove_const< + typename boost::remove_reference<ForwardIterator>::type + >::type + type; + }; + + template<typename ForwardIterator> + ForwardIterator operator()(ForwardIterator x) const + { + return std::advance( + x + , static_cast<typename std::iterator_traits<ForwardIterator>::difference_type>(1) + ); + } + + template<typename ForwardIterator> + ForwardIterator operator()( + ForwardIterator x + , typename std::iterator_traits<ForwardIterator>::difference_type n + ) const + { + return std::advance(x, n); + } + }; + + // A PolymorphicFunctionObject wrapping std::prior + struct prior + { + BOOST_PROTO_CALLABLE() + + template<typename Sig> + struct result; + + template<typename This, typename BidirectionalIterator> + struct result<This(BidirectionalIterator)> + { + typedef + typename boost::remove_const< + typename boost::remove_reference<BidirectionalIterator>::type + >::type + type; + }; + + template<typename This, typename BidirectionalIterator, typename Distance> + struct result<This(BidirectionalIterator, Distance)> + { + typedef + typename boost::remove_const< + typename boost::remove_reference<BidirectionalIterator>::type + >::type + type; + }; + + template<typename BidirectionalIterator> + BidirectionalIterator operator()(BidirectionalIterator x) const + { + return std::advance( + x + , -static_cast<typename std::iterator_traits<BidirectionalIterator>::difference_type>(1) + ); + } + + template<typename BidirectionalIterator> + BidirectionalIterator operator()( + BidirectionalIterator x + , typename std::iterator_traits<BidirectionalIterator>::difference_type n + ) const + { + return std::advance(x, -n); + } + }; + +}}} + +#endif diff --git a/boost/proto/fusion.hpp b/boost/proto/fusion.hpp index 198a34503d..21763d3139 100644 --- a/boost/proto/fusion.hpp +++ b/boost/proto/fusion.hpp @@ -21,12 +21,14 @@ #include <boost/fusion/include/iterator_base.hpp> #include <boost/fusion/include/intrinsic.hpp> #include <boost/fusion/include/single_view.hpp> -#include <boost/fusion/include/transform_view.hpp> +#include <boost/fusion/include/transform.hpp> +#include <boost/fusion/include/as_list.hpp> #include <boost/fusion/include/is_segmented.hpp> #include <boost/fusion/sequence/comparison/enable_comparison.hpp> #include <boost/proto/proto_fwd.hpp> #include <boost/proto/traits.hpp> #include <boost/proto/eval.hpp> +#include <boost/proto/make_expr.hpp> #ifdef BOOST_MSVC #pragma warning(push) @@ -46,7 +48,12 @@ namespace boost { namespace proto typedef Expr expr_type; static const long index = Pos; typedef fusion::random_access_traversal_tag category; - typedef tag::proto_expr_iterator fusion_tag; + typedef + tag::proto_expr_iterator< + typename Expr::proto_tag + , typename Expr::proto_domain + > + fusion_tag; explicit expr_iterator(Expr &e) : expr(e) @@ -55,20 +62,6 @@ namespace boost { namespace proto Expr &expr; }; - template<typename Expr> - struct flat_view - { - typedef Expr expr_type; - typedef fusion::forward_traversal_tag category; - typedef tag::proto_flat_view fusion_tag; - - explicit flat_view(Expr &e) - : expr_(e) - {} - - Expr &expr_; - }; - template<typename Tag> struct as_element { @@ -103,6 +96,33 @@ namespace boost { namespace proto return typename result<as_element(Expr const &)>::type(e); } }; + + template<typename Expr> + struct flat_view + : fusion::sequence_base<flat_view<Expr> > + { + typedef fusion::forward_traversal_tag category; + typedef + tag::proto_flat_view< + typename Expr::proto_tag + , typename Expr::proto_domain + > + fusion_tag; + typedef + typename fusion::result_of::as_list< + typename fusion::result_of::transform< + Expr + , as_element<typename Expr::proto_tag> + >::type + >::type + segments_type; + + explicit flat_view(Expr &e) + : segs_(fusion::as_list(fusion::transform(e, as_element<typename Expr::proto_tag>()))) + {} + + segments_type segs_; + }; } namespace result_of @@ -250,8 +270,8 @@ namespace boost { namespace fusion template<typename Tag> struct is_sequence_impl; - template<> - struct is_sequence_impl<proto::tag::proto_flat_view> + template<typename Tag, typename Domain> + struct is_sequence_impl<proto::tag::proto_flat_view<Tag, Domain> > { template<typename Sequence> struct apply @@ -259,8 +279,8 @@ namespace boost { namespace fusion {}; }; - template<> - struct is_sequence_impl<proto::tag::proto_expr> + template<typename Tag, typename Domain> + struct is_sequence_impl<proto::tag::proto_expr<Tag, Domain> > { template<typename Sequence> struct apply @@ -271,8 +291,8 @@ namespace boost { namespace fusion template<typename Tag> struct is_view_impl; - template<> - struct is_view_impl<proto::tag::proto_flat_view> + template<typename Tag, typename Domain> + struct is_view_impl<proto::tag::proto_flat_view<Tag, Domain> > { template<typename Sequence> struct apply @@ -280,8 +300,8 @@ namespace boost { namespace fusion {}; }; - template<> - struct is_view_impl<proto::tag::proto_expr> + template<typename Tag, typename Domain> + struct is_view_impl<proto::tag::proto_expr<Tag, Domain> > { template<typename Sequence> struct apply @@ -292,8 +312,8 @@ namespace boost { namespace fusion template<typename Tag> struct value_of_impl; - template<> - struct value_of_impl<proto::tag::proto_expr_iterator> + template<typename Tag, typename Domain> + struct value_of_impl<proto::tag::proto_expr_iterator<Tag, Domain> > { template< typename Iterator @@ -323,8 +343,8 @@ namespace boost { namespace fusion template<typename Tag> struct deref_impl; - template<> - struct deref_impl<proto::tag::proto_expr_iterator> + template<typename Tag, typename Domain> + struct deref_impl<proto::tag::proto_expr_iterator<Tag, Domain> > { template< typename Iterator @@ -364,8 +384,8 @@ namespace boost { namespace fusion template<typename Tag> struct advance_impl; - template<> - struct advance_impl<proto::tag::proto_expr_iterator> + template<typename Tag, typename Domain> + struct advance_impl<proto::tag::proto_expr_iterator<Tag, Domain> > { template<typename Iterator, typename N> struct apply @@ -387,8 +407,8 @@ namespace boost { namespace fusion template<typename Tag> struct distance_impl; - template<> - struct distance_impl<proto::tag::proto_expr_iterator> + template<typename Tag, typename Domain> + struct distance_impl<proto::tag::proto_expr_iterator<Tag, Domain> > { template<typename IteratorFrom, typename IteratorTo> struct apply @@ -399,32 +419,32 @@ namespace boost { namespace fusion template<typename Tag> struct next_impl; - template<> - struct next_impl<proto::tag::proto_expr_iterator> + template<typename Tag, typename Domain> + struct next_impl<proto::tag::proto_expr_iterator<Tag, Domain> > { template<typename Iterator> struct apply - : advance_impl<proto::tag::proto_expr_iterator>::template apply<Iterator, mpl::long_<1> > + : advance_impl<proto::tag::proto_expr_iterator<Tag, Domain> >::template apply<Iterator, mpl::long_<1> > {}; }; template<typename Tag> struct prior_impl; - template<> - struct prior_impl<proto::tag::proto_expr_iterator> + template<typename Tag, typename Domain> + struct prior_impl<proto::tag::proto_expr_iterator<Tag, Domain> > { template<typename Iterator> struct apply - : advance_impl<proto::tag::proto_expr_iterator>::template apply<Iterator, mpl::long_<-1> > + : advance_impl<proto::tag::proto_expr_iterator<Tag, Domain> >::template apply<Iterator, mpl::long_<-1> > {}; }; template<typename Tag> struct category_of_impl; - template<> - struct category_of_impl<proto::tag::proto_expr> + template<typename Tag, typename Domain> + struct category_of_impl<proto::tag::proto_expr<Tag, Domain> > { template<typename Sequence> struct apply @@ -436,8 +456,8 @@ namespace boost { namespace fusion template<typename Tag> struct size_impl; - template<> - struct size_impl<proto::tag::proto_expr> + template<typename Tag, typename Domain> + struct size_impl<proto::tag::proto_expr<Tag, Domain> > { template<typename Sequence> struct apply @@ -448,8 +468,8 @@ namespace boost { namespace fusion template<typename Tag> struct begin_impl; - template<> - struct begin_impl<proto::tag::proto_expr> + template<typename Tag, typename Domain> + struct begin_impl<proto::tag::proto_expr<Tag, Domain> > { template<typename Sequence> struct apply @@ -466,8 +486,8 @@ namespace boost { namespace fusion template<typename Tag> struct end_impl; - template<> - struct end_impl<proto::tag::proto_expr> + template<typename Tag, typename Domain> + struct end_impl<proto::tag::proto_expr<Tag, Domain> > { template<typename Sequence> struct apply @@ -489,8 +509,8 @@ namespace boost { namespace fusion template<typename Tag> struct value_at_impl; - template<> - struct value_at_impl<proto::tag::proto_expr> + template<typename Tag, typename Domain> + struct value_at_impl<proto::tag::proto_expr<Tag, Domain> > { template< typename Sequence @@ -521,8 +541,8 @@ namespace boost { namespace fusion template<typename Tag> struct at_impl; - template<> - struct at_impl<proto::tag::proto_expr> + template<typename Tag, typename Domain> + struct at_impl<proto::tag::proto_expr<Tag, Domain> > { template< typename Sequence @@ -561,10 +581,55 @@ namespace boost { namespace fusion }; template<typename Tag> + struct convert_impl; + + template<typename Tag, typename Domain> + struct convert_impl<proto::tag::proto_expr<Tag, Domain> > + { + template<typename Sequence> + struct apply + { + typedef + typename proto::result_of::unpack_expr< + Tag + , Domain + , Sequence + >::type + type; + + static type call(Sequence& seq) + { + return proto::unpack_expr<Tag, Domain>(seq); + } + }; + }; + + template<typename Tag, typename Domain> + struct convert_impl<proto::tag::proto_flat_view<Tag, Domain> > + { + template<typename Sequence> + struct apply + { + typedef + typename proto::result_of::unpack_expr< + Tag + , Domain + , Sequence + >::type + type; + + static type call(Sequence& seq) + { + return proto::unpack_expr<Tag, Domain>(seq); + } + }; + }; + + template<typename Tag> struct is_segmented_impl; - template<> - struct is_segmented_impl<proto::tag::proto_flat_view> + template<typename Tag, typename Domain> + struct is_segmented_impl<proto::tag::proto_flat_view<Tag, Domain> > { template<typename Iterator> struct apply @@ -575,30 +640,23 @@ namespace boost { namespace fusion template<typename Tag> struct segments_impl; - template<> - struct segments_impl<proto::tag::proto_flat_view> + template<typename Tag, typename Domain> + struct segments_impl<proto::tag::proto_flat_view<Tag, Domain> > { template<typename Sequence> struct apply { - typedef typename Sequence::expr_type::proto_tag proto_tag; - - typedef - fusion::transform_view< - typename Sequence::expr_type - , proto::detail::as_element<proto_tag> - > - type; - + typedef typename Sequence::segments_type const &type; + static type call(Sequence &sequence) { - return type(sequence.expr_, proto::detail::as_element<proto_tag>()); + return sequence.segs_; } }; }; - template<> - struct category_of_impl<proto::tag::proto_flat_view> + template<typename Tag, typename Domain> + struct category_of_impl<proto::tag::proto_flat_view<Tag, Domain> > { template<typename Sequence> struct apply @@ -606,7 +664,6 @@ namespace boost { namespace fusion typedef forward_traversal_tag type; }; }; - } namespace traits diff --git a/boost/proto/generate.hpp b/boost/proto/generate.hpp index f6eab4d966..476274118e 100644 --- a/boost/proto/generate.hpp +++ b/boost/proto/generate.hpp @@ -24,7 +24,7 @@ #include <boost/proto/proto_fwd.hpp> #include <boost/proto/args.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif @@ -116,11 +116,7 @@ namespace boost { namespace proto /// \return expr template<typename Expr> BOOST_FORCEINLINE - #ifdef BOOST_PROTO_STRICT_RESULT_OF - Expr - #else - Expr const & - #endif + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(Expr, Expr const &) operator ()(Expr const &e) const { return e; @@ -231,6 +227,28 @@ namespace boost { namespace proto Extends<Expr> that = {e}; return that; } + + // Work-around for: + // https://connect.microsoft.com/VisualStudio/feedback/details/765449/codegen-stack-corruption-using-runtime-checks-when-aggregate-initializing-struct + #if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1700)) + template<typename Class, typename Member> + BOOST_FORCEINLINE + Extends<expr<tag::terminal, proto::term<Member Class::*> > > operator ()(expr<tag::terminal, proto::term<Member Class::*> > const &e) const + { + Extends<expr<tag::terminal, proto::term<Member Class::*> > > that; + proto::value(that.proto_expr_) = proto::value(e); + return that; + } + + template<typename Class, typename Member> + BOOST_FORCEINLINE + Extends<basic_expr<tag::terminal, proto::term<Member Class::*> > > operator ()(basic_expr<tag::terminal, proto::term<Member Class::*> > const &e) const + { + Extends<basic_expr<tag::terminal, proto::term<Member Class::*> > > that; + proto::value(that.proto_expr_) = proto::value(e); + return that; + } + #endif }; /// \brief A generator that replaces child nodes held by @@ -445,7 +463,7 @@ namespace boost #endif } -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/make_expr.hpp b/boost/proto/make_expr.hpp index 08ef2f5ce1..720c1bdcbd 100644 --- a/boost/proto/make_expr.hpp +++ b/boost/proto/make_expr.hpp @@ -45,7 +45,7 @@ #include <boost/proto/detail/poly_function.hpp> #include <boost/proto/detail/deprecated.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4180) // qualifier applied to function type has no meaning; ignored # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined @@ -502,7 +502,7 @@ namespace boost { namespace proto }} -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/matches.hpp b/boost/proto/matches.hpp index 5136a5cc7b..09bb4b9d20 100644 --- a/boost/proto/matches.hpp +++ b/boost/proto/matches.hpp @@ -43,7 +43,7 @@ #include <boost/proto/transform/when.hpp> #include <boost/proto/transform/impl.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable:4305) // 'specialization' : truncation from 'const int' to 'bool' #endif @@ -571,11 +571,7 @@ namespace boost { namespace proto /// \param expr An expression /// \return \c e - #ifdef BOOST_PROTO_STRICT_RESULT_OF - result_type - #else - typename impl::expr_param - #endif + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::expr_param) operator()( typename impl::expr_param e , typename impl::state_param @@ -620,11 +616,7 @@ namespace boost { namespace proto /// \param e An expression /// \pre <tt>matches\<Expr,not_\>::value</tt> is \c true. /// \return \c e - #ifdef BOOST_PROTO_STRICT_RESULT_OF - result_type - #else - typename impl::expr_param - #endif + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::expr_param) operator()( typename impl::expr_param e , typename impl::state_param @@ -948,7 +940,7 @@ namespace boost { namespace proto #undef BOOST_PROTO_LOGICAL_typename_G #undef BOOST_PROTO_LOGICAL_G -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/operators.hpp b/boost/proto/operators.hpp index 1f2bad8c2b..7d4195ce1e 100644 --- a/boost/proto/operators.hpp +++ b/boost/proto/operators.hpp @@ -21,7 +21,7 @@ #include <boost/proto/generate.hpp> #include <boost/proto/make_expr.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif @@ -101,7 +101,7 @@ namespace boost { namespace proto #define BOOST_PROTO_UNARY_OP_IS_POSTFIX_0 #define BOOST_PROTO_UNARY_OP_IS_POSTFIX_1 , int -#ifdef BOOST_NO_RVALUE_REFERENCES +#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES #define BOOST_PROTO_DEFINE_UNARY_OPERATOR(OP, TAG, TRAIT, DOMAIN, POST) \ template<typename Arg> \ @@ -325,7 +325,7 @@ namespace boost { namespace proto // can use BOOST_PROTO_DEFINE_OPERATORS to define Proto operator overloads that work // with their own terminal types. -#ifdef BOOST_NO_RVALUE_REFERENCES +#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES #define BOOST_PROTO_APPLY_UNARY_(TRAIT, ARG) \ boost::mpl::and_< \ @@ -371,7 +371,7 @@ namespace boost { namespace proto }} -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/proto_fwd.hpp b/boost/proto/proto_fwd.hpp index 6fb25bfcf5..a1a25987f1 100644 --- a/boost/proto/proto_fwd.hpp +++ b/boost/proto/proto_fwd.hpp @@ -25,6 +25,7 @@ #include <boost/type_traits/remove_const.hpp> #include <boost/type_traits/remove_reference.hpp> #include <boost/mpl/aux_/config/ttp.hpp> +#include <boost/utility/result_of.hpp> #ifndef BOOST_PROTO_MAX_ARITY # define BOOST_PROTO_MAX_ARITY 10 @@ -92,18 +93,13 @@ # endif #endif -#ifndef BOOST_NO_DECLTYPE_N3276 +#ifdef BOOST_NO_CXX11_DECLTYPE_N3276 # // Proto can only use the decltype-based result_of if N3276 has been # // implemented by the compiler. # // See http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2011/n3276.pdf # ifndef BOOST_PROTO_USE_NORMAL_RESULT_OF # define BOOST_PROTO_USE_NORMAL_RESULT_OF # endif -# // If we're using the decltype-based result_of, we need to be a bit -# // stricter about the return types of some functions. -# ifndef BOOST_PROTO_STRICT_RESULT_OF -# define BOOST_PROTO_STRICT_RESULT_OF -# endif #endif // Unless compiler support is there, use tr1_result_of instead of @@ -114,11 +110,20 @@ # define BOOST_PROTO_RESULT_OF boost::tr1_result_of #endif +// If we're using the decltype-based result_of, we need to be a bit +// stricter about the return types of some functions. +#if defined(BOOST_RESULT_OF_USE_DECLTYPE) && defined(BOOST_PROTO_USE_NORMAL_RESULT_OF) +# define BOOST_PROTO_STRICT_RESULT_OF +# define BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(X, Y) X +#else +# define BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(X, Y) Y +#endif + #ifdef BOOST_MPL_CFG_EXTENDED_TEMPLATE_PARAMETERS_MATCHING # define BOOST_PROTO_EXTENDED_TEMPLATE_PARAMETERS_MATCHING #endif -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # define BOOST_PROTO_DISABLE_MSVC_C4522 __pragma(warning(disable : 4522)) // 'class' : multiple assignment operators specified # define BOOST_PROTO_DISABLE_MSVC_C4714 __pragma(warning(disable : 4714)) // function 'xxx' marked as __forceinline not inlined #else @@ -217,6 +222,9 @@ namespace boost { namespace proto template<typename T, typename Void = void> struct is_aggregate_; + + template<typename Expr> + struct flat_view; } typedef detail::ignore const ignore; @@ -291,9 +299,9 @@ namespace boost { namespace proto struct function; // Fusion tags - struct proto_expr; - struct proto_expr_iterator; - struct proto_flat_view; + template<typename Tag, typename Domain> struct proto_expr; + template<typename Tag, typename Domain> struct proto_expr_iterator; + template<typename Tag, typename Domain> struct proto_flat_view; } } @@ -485,6 +493,14 @@ namespace boost { namespace proto template<typename Tag, typename DomainOrSequence, typename SequenceOrVoid = void, typename Void = void> struct unpack_expr; + template<typename T> + struct as_env; + + template<typename Env, typename Tag> + struct has_env_var; + + template<typename Env, typename Tag> + struct env_var; } template<typename T, typename Void = void> @@ -496,6 +512,9 @@ namespace boost { namespace proto template<typename SubDomain, typename SuperDomain> struct is_sub_domain_of; + template<typename T, typename Void = void> + struct is_env; + template<typename Expr> struct arity_of; @@ -588,6 +607,14 @@ namespace boost { namespace proto template<long N> struct child_c; + struct as_env; + + template<typename Tag> + struct has_env_var; + + template<typename Tag> + struct env_var; + template<typename Tag, typename Domain = deduce_domain> struct make_expr; @@ -730,6 +757,29 @@ namespace boost { namespace proto BOOST_PROTO_CALLABLE() }; + namespace envns_ + { + struct key_not_found; + + struct empty_env; + + typedef int empty_state; + + template<typename Tag, typename Value, typename Base = empty_env> + struct env; + + struct data_type; + + struct transforms_type; + } + + using envns_::key_not_found; + using envns_::empty_env; + using envns_::empty_state; + using envns_::env; + using envns_::data_type; + using envns_::transforms_type; + struct external_transform; template<typename PrimitiveTransform = void, typename X = void> @@ -770,7 +820,7 @@ namespace boost { namespace proto template<typename Sequence, typename State, typename Fun> struct reverse_fold_tree; - template<typename Grammar> + template<typename Grammar, typename Domain = deduce_domain> struct pass_through; template<typename Grammar = detail::_default> @@ -821,12 +871,14 @@ namespace boost { namespace proto struct _byref; struct _byval; + template<typename Tag> + struct _env_var; + + struct _env; + template<typename T> struct is_extension; - //namespace exops - //{} - namespace exops = exprns_; }} // namespace boost::proto diff --git a/boost/proto/traits.hpp b/boost/proto/traits.hpp index 05263b14d0..f1a83fca03 100644 --- a/boost/proto/traits.hpp +++ b/boost/proto/traits.hpp @@ -32,7 +32,7 @@ #include <boost/proto/domain.hpp> #include <boost/proto/transform/pass_through.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # if BOOST_WORKAROUND( BOOST_MSVC, >= 1400 ) # pragma warning(disable: 4180) // warning C4180: qualifier applied to function type has no meaning; ignored @@ -116,7 +116,7 @@ namespace boost { namespace proto : mpl::false_ {}; - #if BOOST_WORKAROUND(__GNUC__, == 3) || (__GNUC__ == 4 && __GNUC_MINOR__ == 0) + #if BOOST_WORKAROUND(__GNUC__, == 3) || (BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0) // work around GCC bug template<typename Tag, typename Args, long N> struct is_callable<proto::expr<Tag, Args, N> > @@ -398,11 +398,7 @@ namespace boost { namespace proto /// \return \c e /// \throw nothrow BOOST_FORCEINLINE - #ifdef BOOST_PROTO_STRICT_RESULT_OF - result_type - #else - typename impl::expr_param - #endif + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::expr_param) operator ()( typename impl::expr_param e , typename impl::state_param @@ -432,7 +428,7 @@ namespace boost { namespace proto template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<if_else_, Expr, State, Data> + : detail::pass_through_impl<if_else_, deduce_domain, Expr, State, Data> {}; /// INTERNAL ONLY @@ -469,11 +465,7 @@ namespace boost { namespace proto /// \return \c e /// \throw nothrow BOOST_FORCEINLINE - #ifdef BOOST_PROTO_STRICT_RESULT_OF - result_type - #else - typename impl::expr_param - #endif + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::expr_param) operator ()( typename impl::expr_param e , typename impl::state_param @@ -507,7 +499,7 @@ namespace boost { namespace proto template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<unary_expr, Expr, State, Data> + : detail::pass_through_impl<unary_expr, deduce_domain, Expr, State, Data> {}; /// INTERNAL ONLY @@ -533,7 +525,7 @@ namespace boost { namespace proto template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<binary_expr, Expr, State, Data> + : detail::pass_through_impl<binary_expr, deduce_domain, Expr, State, Data> {}; /// INTERNAL ONLY @@ -554,7 +546,7 @@ namespace boost { namespace proto \ template<typename Expr, typename State, typename Data> \ struct impl \ - : detail::pass_through_impl<Op, Expr, State, Data> \ + : detail::pass_through_impl<Op, deduce_domain, Expr, State, Data> \ {}; \ \ typedef proto::tag::Op proto_tag; \ @@ -572,7 +564,7 @@ namespace boost { namespace proto \ template<typename Expr, typename State, typename Data> \ struct impl \ - : detail::pass_through_impl<Op, Expr, State, Data> \ + : detail::pass_through_impl<Op, deduce_domain, Expr, State, Data> \ {}; \ \ typedef proto::tag::Op proto_tag; \ @@ -1145,7 +1137,7 @@ namespace boost { namespace proto /// \brief Return the value stored within the specified Proto /// terminal expression. /// - /// Return the the value stored within the specified Proto + /// Return the value stored within the specified Proto /// terminal expression. The value is returned by /// reference. /// @@ -1259,7 +1251,7 @@ namespace boost { namespace proto }} -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/transform.hpp b/boost/proto/transform.hpp index d796ba5c0d..ae376d722a 100644 --- a/boost/proto/transform.hpp +++ b/boost/proto/transform.hpp @@ -12,6 +12,7 @@ #include <boost/proto/transform/arg.hpp> #include <boost/proto/transform/call.hpp> #include <boost/proto/transform/default.hpp> +#include <boost/proto/transform/env.hpp> #include <boost/proto/transform/fold.hpp> #include <boost/proto/transform/fold_tree.hpp> #include <boost/proto/transform/integral_c.hpp> diff --git a/boost/proto/transform/arg.hpp b/boost/proto/transform/arg.hpp index ac41fa38ee..9fdf80e5b4 100644 --- a/boost/proto/transform/arg.hpp +++ b/boost/proto/transform/arg.hpp @@ -9,10 +9,12 @@ #ifndef BOOST_PROTO_TRANSFORM_ARG_HPP_EAN_11_01_2007 #define BOOST_PROTO_TRANSFORM_ARG_HPP_EAN_11_01_2007 +#include <boost/mpl/if.hpp> #include <boost/proto/proto_fwd.hpp> #include <boost/proto/traits.hpp> #include <boost/proto/transform/impl.hpp> #include <boost/type_traits/is_array.hpp> +#include <boost/proto/transform/env.hpp> namespace boost { namespace proto { @@ -38,11 +40,7 @@ namespace boost { namespace proto /// \param e The current expression. /// \return \c e /// \throw nothrow - #ifdef BOOST_PROTO_STRICT_RESULT_OF - result_type - #else - typename impl::expr_param - #endif + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::expr_param) operator()( typename impl::expr_param e , typename impl::state_param @@ -75,11 +73,7 @@ namespace boost { namespace proto /// \param s The current state. /// \return \c s /// \throw nothrow - #ifdef BOOST_PROTO_STRICT_RESULT_OF - result_type - #else - typename impl::state_param - #endif + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::state_param) operator ()( typename impl::expr_param , typename impl::state_param s @@ -105,28 +99,13 @@ namespace boost { namespace proto struct _data : transform<_data> { template<typename Expr, typename State, typename Data> - struct impl : transform_impl<Expr, State, Data> - { - typedef Data result_type; - - /// Returns the current data. - /// \param d The current data. - /// \return \c d - /// \throw nothrow - #ifdef BOOST_PROTO_STRICT_RESULT_OF - result_type - #else - typename impl::data_param - #endif - operator ()( - typename impl::expr_param - , typename impl::state_param - , typename impl::data_param d - ) const - { - return d; - } - }; + struct impl + : mpl::if_c< + is_env<Data>::value + , _env_var<data_type> + , _env + >::type::template impl<Expr, State, Data> + {}; }; /// \brief A PrimitiveTransform that returns N-th child of the current diff --git a/boost/proto/transform/call.hpp b/boost/proto/transform/call.hpp index 7d87c906d6..1e050113c0 100644 --- a/boost/proto/transform/call.hpp +++ b/boost/proto/transform/call.hpp @@ -9,7 +9,7 @@ #ifndef BOOST_PROTO_TRANSFORM_CALL_HPP_EAN_11_02_2007 #define BOOST_PROTO_TRANSFORM_CALL_HPP_EAN_11_02_2007 -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable: 4714) // function 'xxx' marked as __forceinline not inlined #endif @@ -394,7 +394,7 @@ namespace boost { namespace proto }} // namespace boost::proto -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/transform/default.hpp b/boost/proto/transform/default.hpp index 26a4682415..cac2d6eee8 100644 --- a/boost/proto/transform/default.hpp +++ b/boost/proto/transform/default.hpp @@ -543,7 +543,7 @@ namespace boost { namespace proto ) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (BOOST_PROTO_DEFAULT_EVAL(~, 1, e))) ->* BOOST_PROTO_DEFAULT_EVAL(~, 0, e) @@ -559,7 +559,7 @@ namespace boost { namespace proto ) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (BOOST_PROTO_DEFAULT_EVAL(~, 1, e))) ->* BOOST_PROTO_DEFAULT_EVAL(~, 0, e) diff --git a/boost/proto/transform/detail/default_function_impl.hpp b/boost/proto/transform/detail/default_function_impl.hpp index e46d8368db..a8f421c095 100644 --- a/boost/proto/transform/detail/default_function_impl.hpp +++ b/boost/proto/transform/detail/default_function_impl.hpp @@ -84,7 +84,7 @@ ) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (BOOST_PROTO_DEFAULT_EVAL(~, 1, e))) ->* BOOST_PROTO_DEFAULT_EVAL(~, 0, e) diff --git a/boost/proto/transform/detail/make_gcc_workaround.hpp b/boost/proto/transform/detail/make_gcc_workaround.hpp index dae573dfcc..b3b7dea1c9 100644 --- a/boost/proto/transform/detail/make_gcc_workaround.hpp +++ b/boost/proto/transform/detail/make_gcc_workaround.hpp @@ -1,6 +1,6 @@ #if !defined(BOOST_PROTO_DONT_USE_PREPROCESSED_FILES) - #if BOOST_WORKAROUND(__GNUC__, == 3) || (__GNUC__ == 4 && __GNUC_MINOR__ == 0) + #if BOOST_WORKAROUND(__GNUC__, == 3) || (BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0) #include <boost/proto/transform/detail/preprocessed/make_gcc_workaround.hpp> #endif @@ -29,7 +29,7 @@ #pragma wave option(preserve: 1) #endif - #if BOOST_WORKAROUND(__GNUC__, == 3) || (__GNUC__ == 4 && __GNUC_MINOR__ == 0) || \ + #if BOOST_WORKAROUND(__GNUC__, == 3) || (BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0) || \ (defined(__WAVE__) && defined(BOOST_PROTO_CREATE_PREPROCESSED_FILES)) #define BOOST_PP_ITERATION_PARAMS_1 \ diff --git a/boost/proto/transform/detail/pack.hpp b/boost/proto/transform/detail/pack.hpp index 863e7a02c4..20a8ce3149 100644 --- a/boost/proto/transform/detail/pack.hpp +++ b/boost/proto/transform/detail/pack.hpp @@ -26,7 +26,7 @@ #include <boost/type_traits/is_same.hpp> #include <boost/proto/proto_fwd.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable: 4348) // redefinition of default parameter #endif @@ -90,7 +90,7 @@ namespace boost { namespace proto } }} -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/transform/detail/pass_through_impl.hpp b/boost/proto/transform/detail/pass_through_impl.hpp index 23e3534822..03ac568b6b 100644 --- a/boost/proto/transform/detail/pass_through_impl.hpp +++ b/boost/proto/transform/detail/pass_through_impl.hpp @@ -54,15 +54,22 @@ #define N BOOST_PP_ITERATION() - template<typename Grammar, typename Expr, typename State, typename Data> - struct pass_through_impl<Grammar, Expr, State, Data, N> + template<typename Grammar, typename Domain, typename Expr, typename State, typename Data> + struct pass_through_impl<Grammar, Domain, Expr, State, Data, N> : transform_impl<Expr, State, Data> { typedef typename pass_through_impl::expr unref_expr; + typedef + typename mpl::if_c< + is_same<Domain, deduce_domain>::value + , typename unref_expr::proto_domain + , Domain + >::type + result_domain; typedef typename base_expr< - typename unref_expr::proto_domain + result_domain , typename unref_expr::proto_tag , BOOST_PP_CAT(list, N)< BOOST_PP_ENUM(N, BOOST_PROTO_DEFINE_TRANSFORM_TYPE, ~) @@ -70,11 +77,12 @@ >::type expr_type; - typedef typename unref_expr::proto_generator proto_generator; - typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type const result_type; + typedef typename result_domain::proto_generator proto_generator; + typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type result_type; BOOST_FORCEINLINE - result_type const operator ()( + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, result_type const) + operator ()( typename pass_through_impl::expr_param e , typename pass_through_impl::state_param s , typename pass_through_impl::data_param d diff --git a/boost/proto/transform/detail/preprocessed/default_function_impl.hpp b/boost/proto/transform/detail/preprocessed/default_function_impl.hpp index 9086c9a322..72ff60e80f 100644 --- a/boost/proto/transform/detail/preprocessed/default_function_impl.hpp +++ b/boost/proto/transform/detail/preprocessed/default_function_impl.hpp @@ -47,7 +47,7 @@ ) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (typename Grammar::template impl<e1, State, Data>()( proto::child_c< 1>( e), s, d ))) ->* typename Grammar::template impl<e0, State, Data>()( proto::child_c< 0>( e), s, d ) @@ -95,7 +95,7 @@ ) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (typename Grammar::template impl<e1, State, Data>()( proto::child_c< 1>( e), s, d ))) ->* typename Grammar::template impl<e0, State, Data>()( proto::child_c< 0>( e), s, d ) @@ -143,7 +143,7 @@ ) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (typename Grammar::template impl<e1, State, Data>()( proto::child_c< 1>( e), s, d ))) ->* typename Grammar::template impl<e0, State, Data>()( proto::child_c< 0>( e), s, d ) @@ -191,7 +191,7 @@ ) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (typename Grammar::template impl<e1, State, Data>()( proto::child_c< 1>( e), s, d ))) ->* typename Grammar::template impl<e0, State, Data>()( proto::child_c< 0>( e), s, d ) @@ -239,7 +239,7 @@ ) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (typename Grammar::template impl<e1, State, Data>()( proto::child_c< 1>( e), s, d ))) ->* typename Grammar::template impl<e0, State, Data>()( proto::child_c< 0>( e), s, d ) @@ -287,7 +287,7 @@ ) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (typename Grammar::template impl<e1, State, Data>()( proto::child_c< 1>( e), s, d ))) ->* typename Grammar::template impl<e0, State, Data>()( proto::child_c< 0>( e), s, d ) @@ -335,7 +335,7 @@ ) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (typename Grammar::template impl<e1, State, Data>()( proto::child_c< 1>( e), s, d ))) ->* typename Grammar::template impl<e0, State, Data>()( proto::child_c< 0>( e), s, d ) @@ -383,7 +383,7 @@ ) const { BOOST_PROTO_USE_GET_POINTER(); - typedef typename detail::classtypeof<function_type>::type class_type; + typedef typename detail::class_member_traits<function_type>::class_type class_type; return ( BOOST_PROTO_GET_POINTER(class_type, (typename Grammar::template impl<e1, State, Data>()( proto::child_c< 1>( e), s, d ))) ->* typename Grammar::template impl<e0, State, Data>()( proto::child_c< 0>( e), s, d ) diff --git a/boost/proto/transform/detail/preprocessed/pass_through_impl.hpp b/boost/proto/transform/detail/preprocessed/pass_through_impl.hpp index 3a1620f18d..401b200cd4 100644 --- a/boost/proto/transform/detail/preprocessed/pass_through_impl.hpp +++ b/boost/proto/transform/detail/preprocessed/pass_through_impl.hpp @@ -7,24 +7,32 @@ // Copyright 2008 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) - template<typename Grammar, typename Expr, typename State, typename Data> - struct pass_through_impl<Grammar, Expr, State, Data, 1> + template<typename Grammar, typename Domain, typename Expr, typename State, typename Data> + struct pass_through_impl<Grammar, Domain, Expr, State, Data, 1> : transform_impl<Expr, State, Data> { typedef typename pass_through_impl::expr unref_expr; typedef + typename mpl::if_c< + is_same<Domain, deduce_domain>::value + , typename unref_expr::proto_domain + , Domain + >::type + result_domain; + typedef typename base_expr< - typename unref_expr::proto_domain + result_domain , typename unref_expr::proto_tag , list1< typename Grammar::proto_child0::template impl< typename result_of::child_c<Expr, 0>::type , State , Data >::result_type > >::type expr_type; - typedef typename unref_expr::proto_generator proto_generator; - typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type const result_type; + typedef typename result_domain::proto_generator proto_generator; + typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type result_type; BOOST_FORCEINLINE - result_type const operator ()( + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, result_type const) + operator ()( typename pass_through_impl::expr_param e , typename pass_through_impl::state_param s , typename pass_through_impl::data_param d @@ -40,24 +48,32 @@ return proto_generator()(that); } }; - template<typename Grammar, typename Expr, typename State, typename Data> - struct pass_through_impl<Grammar, Expr, State, Data, 2> + template<typename Grammar, typename Domain, typename Expr, typename State, typename Data> + struct pass_through_impl<Grammar, Domain, Expr, State, Data, 2> : transform_impl<Expr, State, Data> { typedef typename pass_through_impl::expr unref_expr; typedef + typename mpl::if_c< + is_same<Domain, deduce_domain>::value + , typename unref_expr::proto_domain + , Domain + >::type + result_domain; + typedef typename base_expr< - typename unref_expr::proto_domain + result_domain , typename unref_expr::proto_tag , list2< typename Grammar::proto_child0::template impl< typename result_of::child_c<Expr, 0>::type , State , Data >::result_type , typename Grammar::proto_child1::template impl< typename result_of::child_c<Expr, 1>::type , State , Data >::result_type > >::type expr_type; - typedef typename unref_expr::proto_generator proto_generator; - typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type const result_type; + typedef typename result_domain::proto_generator proto_generator; + typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type result_type; BOOST_FORCEINLINE - result_type const operator ()( + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, result_type const) + operator ()( typename pass_through_impl::expr_param e , typename pass_through_impl::state_param s , typename pass_through_impl::data_param d @@ -73,24 +89,32 @@ return proto_generator()(that); } }; - template<typename Grammar, typename Expr, typename State, typename Data> - struct pass_through_impl<Grammar, Expr, State, Data, 3> + template<typename Grammar, typename Domain, typename Expr, typename State, typename Data> + struct pass_through_impl<Grammar, Domain, Expr, State, Data, 3> : transform_impl<Expr, State, Data> { typedef typename pass_through_impl::expr unref_expr; typedef + typename mpl::if_c< + is_same<Domain, deduce_domain>::value + , typename unref_expr::proto_domain + , Domain + >::type + result_domain; + typedef typename base_expr< - typename unref_expr::proto_domain + result_domain , typename unref_expr::proto_tag , list3< typename Grammar::proto_child0::template impl< typename result_of::child_c<Expr, 0>::type , State , Data >::result_type , typename Grammar::proto_child1::template impl< typename result_of::child_c<Expr, 1>::type , State , Data >::result_type , typename Grammar::proto_child2::template impl< typename result_of::child_c<Expr, 2>::type , State , Data >::result_type > >::type expr_type; - typedef typename unref_expr::proto_generator proto_generator; - typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type const result_type; + typedef typename result_domain::proto_generator proto_generator; + typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type result_type; BOOST_FORCEINLINE - result_type const operator ()( + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, result_type const) + operator ()( typename pass_through_impl::expr_param e , typename pass_through_impl::state_param s , typename pass_through_impl::data_param d @@ -106,24 +130,32 @@ return proto_generator()(that); } }; - template<typename Grammar, typename Expr, typename State, typename Data> - struct pass_through_impl<Grammar, Expr, State, Data, 4> + template<typename Grammar, typename Domain, typename Expr, typename State, typename Data> + struct pass_through_impl<Grammar, Domain, Expr, State, Data, 4> : transform_impl<Expr, State, Data> { typedef typename pass_through_impl::expr unref_expr; typedef + typename mpl::if_c< + is_same<Domain, deduce_domain>::value + , typename unref_expr::proto_domain + , Domain + >::type + result_domain; + typedef typename base_expr< - typename unref_expr::proto_domain + result_domain , typename unref_expr::proto_tag , list4< typename Grammar::proto_child0::template impl< typename result_of::child_c<Expr, 0>::type , State , Data >::result_type , typename Grammar::proto_child1::template impl< typename result_of::child_c<Expr, 1>::type , State , Data >::result_type , typename Grammar::proto_child2::template impl< typename result_of::child_c<Expr, 2>::type , State , Data >::result_type , typename Grammar::proto_child3::template impl< typename result_of::child_c<Expr, 3>::type , State , Data >::result_type > >::type expr_type; - typedef typename unref_expr::proto_generator proto_generator; - typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type const result_type; + typedef typename result_domain::proto_generator proto_generator; + typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type result_type; BOOST_FORCEINLINE - result_type const operator ()( + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, result_type const) + operator ()( typename pass_through_impl::expr_param e , typename pass_through_impl::state_param s , typename pass_through_impl::data_param d @@ -139,24 +171,32 @@ return proto_generator()(that); } }; - template<typename Grammar, typename Expr, typename State, typename Data> - struct pass_through_impl<Grammar, Expr, State, Data, 5> + template<typename Grammar, typename Domain, typename Expr, typename State, typename Data> + struct pass_through_impl<Grammar, Domain, Expr, State, Data, 5> : transform_impl<Expr, State, Data> { typedef typename pass_through_impl::expr unref_expr; typedef + typename mpl::if_c< + is_same<Domain, deduce_domain>::value + , typename unref_expr::proto_domain + , Domain + >::type + result_domain; + typedef typename base_expr< - typename unref_expr::proto_domain + result_domain , typename unref_expr::proto_tag , list5< typename Grammar::proto_child0::template impl< typename result_of::child_c<Expr, 0>::type , State , Data >::result_type , typename Grammar::proto_child1::template impl< typename result_of::child_c<Expr, 1>::type , State , Data >::result_type , typename Grammar::proto_child2::template impl< typename result_of::child_c<Expr, 2>::type , State , Data >::result_type , typename Grammar::proto_child3::template impl< typename result_of::child_c<Expr, 3>::type , State , Data >::result_type , typename Grammar::proto_child4::template impl< typename result_of::child_c<Expr, 4>::type , State , Data >::result_type > >::type expr_type; - typedef typename unref_expr::proto_generator proto_generator; - typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type const result_type; + typedef typename result_domain::proto_generator proto_generator; + typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type result_type; BOOST_FORCEINLINE - result_type const operator ()( + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, result_type const) + operator ()( typename pass_through_impl::expr_param e , typename pass_through_impl::state_param s , typename pass_through_impl::data_param d @@ -172,24 +212,32 @@ return proto_generator()(that); } }; - template<typename Grammar, typename Expr, typename State, typename Data> - struct pass_through_impl<Grammar, Expr, State, Data, 6> + template<typename Grammar, typename Domain, typename Expr, typename State, typename Data> + struct pass_through_impl<Grammar, Domain, Expr, State, Data, 6> : transform_impl<Expr, State, Data> { typedef typename pass_through_impl::expr unref_expr; typedef + typename mpl::if_c< + is_same<Domain, deduce_domain>::value + , typename unref_expr::proto_domain + , Domain + >::type + result_domain; + typedef typename base_expr< - typename unref_expr::proto_domain + result_domain , typename unref_expr::proto_tag , list6< typename Grammar::proto_child0::template impl< typename result_of::child_c<Expr, 0>::type , State , Data >::result_type , typename Grammar::proto_child1::template impl< typename result_of::child_c<Expr, 1>::type , State , Data >::result_type , typename Grammar::proto_child2::template impl< typename result_of::child_c<Expr, 2>::type , State , Data >::result_type , typename Grammar::proto_child3::template impl< typename result_of::child_c<Expr, 3>::type , State , Data >::result_type , typename Grammar::proto_child4::template impl< typename result_of::child_c<Expr, 4>::type , State , Data >::result_type , typename Grammar::proto_child5::template impl< typename result_of::child_c<Expr, 5>::type , State , Data >::result_type > >::type expr_type; - typedef typename unref_expr::proto_generator proto_generator; - typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type const result_type; + typedef typename result_domain::proto_generator proto_generator; + typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type result_type; BOOST_FORCEINLINE - result_type const operator ()( + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, result_type const) + operator ()( typename pass_through_impl::expr_param e , typename pass_through_impl::state_param s , typename pass_through_impl::data_param d @@ -205,24 +253,32 @@ return proto_generator()(that); } }; - template<typename Grammar, typename Expr, typename State, typename Data> - struct pass_through_impl<Grammar, Expr, State, Data, 7> + template<typename Grammar, typename Domain, typename Expr, typename State, typename Data> + struct pass_through_impl<Grammar, Domain, Expr, State, Data, 7> : transform_impl<Expr, State, Data> { typedef typename pass_through_impl::expr unref_expr; typedef + typename mpl::if_c< + is_same<Domain, deduce_domain>::value + , typename unref_expr::proto_domain + , Domain + >::type + result_domain; + typedef typename base_expr< - typename unref_expr::proto_domain + result_domain , typename unref_expr::proto_tag , list7< typename Grammar::proto_child0::template impl< typename result_of::child_c<Expr, 0>::type , State , Data >::result_type , typename Grammar::proto_child1::template impl< typename result_of::child_c<Expr, 1>::type , State , Data >::result_type , typename Grammar::proto_child2::template impl< typename result_of::child_c<Expr, 2>::type , State , Data >::result_type , typename Grammar::proto_child3::template impl< typename result_of::child_c<Expr, 3>::type , State , Data >::result_type , typename Grammar::proto_child4::template impl< typename result_of::child_c<Expr, 4>::type , State , Data >::result_type , typename Grammar::proto_child5::template impl< typename result_of::child_c<Expr, 5>::type , State , Data >::result_type , typename Grammar::proto_child6::template impl< typename result_of::child_c<Expr, 6>::type , State , Data >::result_type > >::type expr_type; - typedef typename unref_expr::proto_generator proto_generator; - typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type const result_type; + typedef typename result_domain::proto_generator proto_generator; + typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type result_type; BOOST_FORCEINLINE - result_type const operator ()( + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, result_type const) + operator ()( typename pass_through_impl::expr_param e , typename pass_through_impl::state_param s , typename pass_through_impl::data_param d @@ -238,24 +294,32 @@ return proto_generator()(that); } }; - template<typename Grammar, typename Expr, typename State, typename Data> - struct pass_through_impl<Grammar, Expr, State, Data, 8> + template<typename Grammar, typename Domain, typename Expr, typename State, typename Data> + struct pass_through_impl<Grammar, Domain, Expr, State, Data, 8> : transform_impl<Expr, State, Data> { typedef typename pass_through_impl::expr unref_expr; typedef + typename mpl::if_c< + is_same<Domain, deduce_domain>::value + , typename unref_expr::proto_domain + , Domain + >::type + result_domain; + typedef typename base_expr< - typename unref_expr::proto_domain + result_domain , typename unref_expr::proto_tag , list8< typename Grammar::proto_child0::template impl< typename result_of::child_c<Expr, 0>::type , State , Data >::result_type , typename Grammar::proto_child1::template impl< typename result_of::child_c<Expr, 1>::type , State , Data >::result_type , typename Grammar::proto_child2::template impl< typename result_of::child_c<Expr, 2>::type , State , Data >::result_type , typename Grammar::proto_child3::template impl< typename result_of::child_c<Expr, 3>::type , State , Data >::result_type , typename Grammar::proto_child4::template impl< typename result_of::child_c<Expr, 4>::type , State , Data >::result_type , typename Grammar::proto_child5::template impl< typename result_of::child_c<Expr, 5>::type , State , Data >::result_type , typename Grammar::proto_child6::template impl< typename result_of::child_c<Expr, 6>::type , State , Data >::result_type , typename Grammar::proto_child7::template impl< typename result_of::child_c<Expr, 7>::type , State , Data >::result_type > >::type expr_type; - typedef typename unref_expr::proto_generator proto_generator; - typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type const result_type; + typedef typename result_domain::proto_generator proto_generator; + typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type result_type; BOOST_FORCEINLINE - result_type const operator ()( + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, result_type const) + operator ()( typename pass_through_impl::expr_param e , typename pass_through_impl::state_param s , typename pass_through_impl::data_param d @@ -271,24 +335,32 @@ return proto_generator()(that); } }; - template<typename Grammar, typename Expr, typename State, typename Data> - struct pass_through_impl<Grammar, Expr, State, Data, 9> + template<typename Grammar, typename Domain, typename Expr, typename State, typename Data> + struct pass_through_impl<Grammar, Domain, Expr, State, Data, 9> : transform_impl<Expr, State, Data> { typedef typename pass_through_impl::expr unref_expr; typedef + typename mpl::if_c< + is_same<Domain, deduce_domain>::value + , typename unref_expr::proto_domain + , Domain + >::type + result_domain; + typedef typename base_expr< - typename unref_expr::proto_domain + result_domain , typename unref_expr::proto_tag , list9< typename Grammar::proto_child0::template impl< typename result_of::child_c<Expr, 0>::type , State , Data >::result_type , typename Grammar::proto_child1::template impl< typename result_of::child_c<Expr, 1>::type , State , Data >::result_type , typename Grammar::proto_child2::template impl< typename result_of::child_c<Expr, 2>::type , State , Data >::result_type , typename Grammar::proto_child3::template impl< typename result_of::child_c<Expr, 3>::type , State , Data >::result_type , typename Grammar::proto_child4::template impl< typename result_of::child_c<Expr, 4>::type , State , Data >::result_type , typename Grammar::proto_child5::template impl< typename result_of::child_c<Expr, 5>::type , State , Data >::result_type , typename Grammar::proto_child6::template impl< typename result_of::child_c<Expr, 6>::type , State , Data >::result_type , typename Grammar::proto_child7::template impl< typename result_of::child_c<Expr, 7>::type , State , Data >::result_type , typename Grammar::proto_child8::template impl< typename result_of::child_c<Expr, 8>::type , State , Data >::result_type > >::type expr_type; - typedef typename unref_expr::proto_generator proto_generator; - typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type const result_type; + typedef typename result_domain::proto_generator proto_generator; + typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type result_type; BOOST_FORCEINLINE - result_type const operator ()( + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, result_type const) + operator ()( typename pass_through_impl::expr_param e , typename pass_through_impl::state_param s , typename pass_through_impl::data_param d @@ -304,24 +376,32 @@ return proto_generator()(that); } }; - template<typename Grammar, typename Expr, typename State, typename Data> - struct pass_through_impl<Grammar, Expr, State, Data, 10> + template<typename Grammar, typename Domain, typename Expr, typename State, typename Data> + struct pass_through_impl<Grammar, Domain, Expr, State, Data, 10> : transform_impl<Expr, State, Data> { typedef typename pass_through_impl::expr unref_expr; typedef + typename mpl::if_c< + is_same<Domain, deduce_domain>::value + , typename unref_expr::proto_domain + , Domain + >::type + result_domain; + typedef typename base_expr< - typename unref_expr::proto_domain + result_domain , typename unref_expr::proto_tag , list10< typename Grammar::proto_child0::template impl< typename result_of::child_c<Expr, 0>::type , State , Data >::result_type , typename Grammar::proto_child1::template impl< typename result_of::child_c<Expr, 1>::type , State , Data >::result_type , typename Grammar::proto_child2::template impl< typename result_of::child_c<Expr, 2>::type , State , Data >::result_type , typename Grammar::proto_child3::template impl< typename result_of::child_c<Expr, 3>::type , State , Data >::result_type , typename Grammar::proto_child4::template impl< typename result_of::child_c<Expr, 4>::type , State , Data >::result_type , typename Grammar::proto_child5::template impl< typename result_of::child_c<Expr, 5>::type , State , Data >::result_type , typename Grammar::proto_child6::template impl< typename result_of::child_c<Expr, 6>::type , State , Data >::result_type , typename Grammar::proto_child7::template impl< typename result_of::child_c<Expr, 7>::type , State , Data >::result_type , typename Grammar::proto_child8::template impl< typename result_of::child_c<Expr, 8>::type , State , Data >::result_type , typename Grammar::proto_child9::template impl< typename result_of::child_c<Expr, 9>::type , State , Data >::result_type > >::type expr_type; - typedef typename unref_expr::proto_generator proto_generator; - typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type const result_type; + typedef typename result_domain::proto_generator proto_generator; + typedef typename BOOST_PROTO_RESULT_OF<proto_generator(expr_type)>::type result_type; BOOST_FORCEINLINE - result_type const operator ()( + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, result_type const) + operator ()( typename pass_through_impl::expr_param e , typename pass_through_impl::state_param s , typename pass_through_impl::data_param d diff --git a/boost/proto/transform/env.hpp b/boost/proto/transform/env.hpp new file mode 100644 index 0000000000..81309fa360 --- /dev/null +++ b/boost/proto/transform/env.hpp @@ -0,0 +1,515 @@ +/////////////////////////////////////////////////////////////////////////////// +// env.hpp +// Helpers for producing and consuming tranform env variables. +// +// Copyright 2012 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_TRANSFORM_ENV_HPP_EAN_18_07_2012 +#define BOOST_PROTO_TRANSFORM_ENV_HPP_EAN_18_07_2012 + +#include <boost/config.hpp> +#include <boost/detail/workaround.hpp> +#include <boost/ref.hpp> +#include <boost/utility/enable_if.hpp> +#include <boost/type_traits/is_const.hpp> +#include <boost/type_traits/is_same.hpp> +#include <boost/type_traits/add_const.hpp> +#include <boost/type_traits/add_reference.hpp> +#include <boost/type_traits/remove_const.hpp> +#include <boost/mpl/assert.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/mpl/not.hpp> +#include <boost/proto/proto_fwd.hpp> +#include <boost/proto/transform/impl.hpp> +#include <boost/proto/detail/poly_function.hpp> +#include <boost/proto/detail/is_noncopyable.hpp> + +#ifdef _MSC_VER +# pragma warning(push) +# pragma warning(disable: 4180) // qualifier applied to function type has no meaning; ignored +#endif + +namespace boost +{ + namespace proto + { + namespace detail + { + template<typename T> + struct value_type + { + typedef typename remove_const<T>::type value; + typedef typename add_reference<T>::type reference; + typedef typename mpl::if_c<is_noncopyable<T>::value, reference, value>::type type; + }; + + template<typename T> + struct value_type<T &> + { + typedef T &value; + typedef T &reference; + typedef T &type; + }; + } + + #define BOOST_PROTO_DEFINE_ENV_VAR(TAG, NAME) \ + struct TAG \ + { \ + template<typename Value> \ + boost::proto::env<TAG, Value &> const \ + operator =(boost::reference_wrapper<Value> &value) const \ + { \ + return boost::proto::env<TAG, Value &>(value.get()); \ + } \ + template<typename Value> \ + boost::proto::env<TAG, Value &> const \ + operator =(boost::reference_wrapper<Value> const &value) const \ + { \ + return boost::proto::env<TAG, Value &>(value.get()); \ + } \ + template<typename Value> \ + typename boost::disable_if_c< \ + boost::is_const<Value>::value \ + , boost::proto::env<TAG, typename boost::proto::detail::value_type<Value>::type> \ + >::type const operator =(Value &value) const \ + { \ + return boost::proto::env<TAG, typename boost::proto::detail::value_type<Value>::type>(value); \ + } \ + template<typename Value> \ + boost::proto::env<TAG, typename boost::proto::detail::value_type<Value const>::type> const \ + operator =(Value const &value) const \ + { \ + return boost::proto::env<TAG, typename boost::proto::detail::value_type<Value const>::type>(value); \ + } \ + }; \ + \ + TAG const NAME = {} \ + /**/ + + namespace envns_ + { + //////////////////////////////////////////////////////////////////////////////////////////// + // env + // A transform env is a slot-based storage mechanism, accessible by tag. + template<typename Key, typename Value, typename Base /*= empty_env*/> + struct env + : private Base + { + private: + Value value_; + + public: + typedef Value value_type; + typedef typename add_reference<Value>::type reference; + typedef typename add_reference<typename add_const<Value>::type>::type const_reference; + typedef void proto_environment_; ///< INTERNAL ONLY + + explicit env(const_reference value, Base const &base = Base()) + : Base(base) + , value_(value) + {} + + #if BOOST_WORKAROUND(__GNUC__, == 3) || (BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ <= 2) + /// INTERNAL ONLY + struct found + { + typedef Value type; + typedef typename add_reference<typename add_const<Value>::type>::type const_reference; + }; + + template<typename OtherKey, typename OtherValue = key_not_found> + struct lookup + : mpl::if_c< + is_same<OtherKey, Key>::value + , found + , typename Base::template lookup<OtherKey, OtherValue> + >::type + {}; + #else + /// INTERNAL ONLY + template<typename OtherKey, typename OtherValue = key_not_found> + struct lookup + : Base::template lookup<OtherKey, OtherValue> + {}; + + /// INTERNAL ONLY + template<typename OtherValue> + struct lookup<Key, OtherValue> + { + typedef Value type; + typedef typename add_reference<typename add_const<Value>::type>::type const_reference; + }; + #endif + + // For key-based lookups not intended to fail + using Base::operator[]; + const_reference operator[](Key) const + { + return this->value_; + } + + // For key-based lookups that can fail, use the default if key not found. + using Base::at; + template<typename T> + const_reference at(Key, T const &) const + { + return this->value_; + } + }; + + // define proto::data_type type and proto::data global + BOOST_PROTO_DEFINE_ENV_VAR(data_type, data); + } + + using envns_::data; + + namespace functional + { + //////////////////////////////////////////////////////////////////////////////////////// + // as_env + struct as_env + { + BOOST_PROTO_CALLABLE() + BOOST_PROTO_POLY_FUNCTION() + + /// INTERNAL ONLY + template<typename T, bool B = is_env<T>::value> + struct impl + { + typedef env<data_type, typename detail::value_type<T>::type> result_type; + + result_type const operator()(detail::arg<T> t) const + { + return result_type(t()); + } + }; + + /// INTERNAL ONLY + template<typename T> + struct impl<T, true> + { + typedef T result_type; + + typename add_const<T>::type operator()(detail::arg<T> t) const + { + return t(); + } + }; + + template<typename Sig> + struct result; + + template<typename This, typename T> + struct result<This(T)> + { + typedef typename impl<typename detail::normalize_arg<T>::type>::result_type type; + }; + + template<typename T> + typename impl<typename detail::normalize_arg<T &>::type>::result_type const + operator()(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T)) const + { + return impl<typename detail::normalize_arg<T &>::type>()( + static_cast<typename detail::normalize_arg<T &>::reference>(t) + ); + } + + template<typename T> + typename impl<typename detail::normalize_arg<T const &>::type>::result_type const + operator()(T const &t) const + { + return impl<typename detail::normalize_arg<T const &>::type>()( + static_cast<typename detail::normalize_arg<T const &>::reference>(t) + ); + } + }; + + //////////////////////////////////////////////////////////////////////////////////////// + // has_env_var + template<typename Key> + struct has_env_var + : detail::poly_function<has_env_var<Key> > + { + BOOST_PROTO_CALLABLE() + + template<typename Env, bool IsEnv = is_env<Env>::value> + struct impl + { + typedef + mpl::not_< + is_same< + typename remove_reference<Env>::type::template lookup<Key>::type + , key_not_found + > + > + result_type; + + result_type operator()(detail::arg<Env>) const + { + return result_type(); + } + }; + + template<typename Env> + struct impl<Env, false> + { + typedef mpl::false_ result_type; + + result_type operator()(detail::arg<Env>) const + { + return result_type(); + } + }; + }; + + template<> + struct has_env_var<data_type> + : detail::poly_function<has_env_var<data_type> > + { + BOOST_PROTO_CALLABLE() + + template<typename Env, bool IsEnv = is_env<Env>::value> + struct impl + { + typedef + mpl::not_< + is_same< + typename remove_reference<Env>::type::template lookup<data_type>::type + , key_not_found + > + > + result_type; + + result_type operator()(detail::arg<Env>) const + { + return result_type(); + } + }; + + template<typename Env> + struct impl<Env, false> + { + typedef mpl::true_ result_type; + + result_type operator()(detail::arg<Env>) const + { + return result_type(); + } + }; + }; + + //////////////////////////////////////////////////////////////////////////////////////// + // env_var + template<typename Key> + struct env_var + : detail::poly_function<env_var<Key> > + { + BOOST_PROTO_CALLABLE() + + template<typename Env> + struct impl + { + typedef + typename remove_reference<Env>::type::template lookup<Key>::type + result_type; + + result_type operator()(detail::arg<Env> e) const + { + return e()[Key()]; + } + }; + }; + + template<> + struct env_var<data_type> + : detail::poly_function<env_var<data_type> > + { + BOOST_PROTO_CALLABLE() + + template<typename Env, bool B = is_env<Env>::value> + struct impl + { + typedef Env result_type; + + result_type operator()(detail::arg<Env> e) const + { + return e(); + } + }; + + template<typename Env> + struct impl<Env, true> + { + typedef + typename remove_reference<Env>::type::template lookup<data_type>::type + result_type; + + result_type operator()(detail::arg<Env> e) const + { + return e()[proto::data]; + } + }; + }; + } + + namespace result_of + { + template<typename T> + struct as_env + : BOOST_PROTO_RESULT_OF<functional::as_env(T)> + {}; + + template<typename Env, typename Key> + struct has_env_var + : BOOST_PROTO_RESULT_OF<functional::has_env_var<Key>(Env)>::type + {}; + + template<typename Env, typename Key> + struct env_var + : BOOST_PROTO_RESULT_OF<functional::env_var<Key>(Env)> + {}; + } + + //////////////////////////////////////////////////////////////////////////////////////////// + // as_env + template<typename T> + typename proto::result_of::as_env<T &>::type const as_env(T &t BOOST_PROTO_DISABLE_IF_IS_CONST(T)) + { + return proto::functional::as_env()(t); + } + + template<typename T> + typename proto::result_of::as_env<T const &>::type const as_env(T const &t) + { + return proto::functional::as_env()(t); + } + + //////////////////////////////////////////////////////////////////////////////////////////// + // has_env_var + template<typename Key, typename Env> + typename proto::result_of::has_env_var<Env &, Key>::type has_env_var(Env &e BOOST_PROTO_DISABLE_IF_IS_CONST(Env)) + { + return functional::has_env_var<Key>()(e); + } + + template<typename Key, typename Env> + typename proto::result_of::has_env_var<Env const &, Key>::type has_env_var(Env const &e) + { + return functional::has_env_var<Key>()(e); + } + + //////////////////////////////////////////////////////////////////////////////////////////// + // env_var + template<typename Key, typename Env> + typename proto::result_of::env_var<Env &, Key>::type env_var(Env &e BOOST_PROTO_DISABLE_IF_IS_CONST(Env)) + { + return functional::env_var<Key>()(e); + } + + template<typename Key, typename Env> + typename proto::result_of::env_var<Env const &, Key>::type env_var(Env const &e) + { + return functional::env_var<Key>()(e); + } + + namespace envns_ + { + //////////////////////////////////////////////////////////////////////////////////////// + // env operator, + template<typename T, typename T1, typename V1> + inline typename disable_if_c< + is_const<T>::value + , env<T1, V1, BOOST_PROTO_UNCVREF(typename result_of::as_env<T &>::type)> + >::type const operator,(T &t, env<T1, V1> const &head) + { + return env<T1, V1, BOOST_PROTO_UNCVREF(typename result_of::as_env<T &>::type)>( + head[T1()] + , proto::as_env(t) + ); + } + + template<typename T, typename T1, typename V1> + inline env<T1, V1, BOOST_PROTO_UNCVREF(typename result_of::as_env<T const &>::type)> const + operator,(T const &t, env<T1, V1> const &head) + { + return env<T1, V1, BOOST_PROTO_UNCVREF(typename result_of::as_env<T const &>::type)>( + head[T1()] + , proto::as_env(t) + ); + } + } + + //////////////////////////////////////////////////////////////////////////////////////////// + // _env_var + template<typename Key> + struct _env_var + : proto::transform<_env_var<Key> > + { + template<typename Expr, typename State, typename Data> + struct impl + : transform_impl<Expr, State, Data> + { + typedef typename impl::data::template lookup<Key>::type result_type; + BOOST_MPL_ASSERT_NOT((is_same<result_type, key_not_found>)); // lookup failed + + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::data::template lookup<Key>::const_reference) + operator ()( + typename impl::expr_param + , typename impl::state_param + , typename impl::data_param d + ) const + { + return d[Key()]; + } + }; + }; + + struct _env + : transform<_env> + { + template<typename Expr, typename State, typename Data> + struct impl + : transform_impl<Expr, State, Data> + { + typedef Data result_type; + + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename impl::data_param) + operator ()( + typename impl::expr_param + , typename impl::state_param + , typename impl::data_param d + ) const + { + return d; + } + }; + }; + + /// INTERNAL ONLY + template<typename Key> + struct is_callable<_env_var<Key> > + : mpl::true_ + {}; + + /// INTERNAL ONLY + template<typename Key> + struct is_callable<functional::has_env_var<Key> > + : mpl::true_ + {}; + + /// INTERNAL ONLY + template<typename Key> + struct is_callable<functional::env_var<Key> > + : mpl::true_ + {}; + } +} + +#ifdef _MSC_VER +# pragma warning(pop) +#endif + +#endif diff --git a/boost/proto/transform/fold_tree.hpp b/boost/proto/transform/fold_tree.hpp index ace2c21693..b541a15c00 100644 --- a/boost/proto/transform/fold_tree.hpp +++ b/boost/proto/transform/fold_tree.hpp @@ -69,7 +69,7 @@ namespace boost { namespace proto /// template<typename Tag, typename Fun> /// struct recurse_if_ /// : if_< - /// // If the current node has type type "Tag" ... + /// // If the current node has type "Tag" ... /// is_same<tag_of<_>, Tag>() /// // ... recurse, otherwise ... /// , fold<_, _state, recurse_if_<Tag, Fun> > @@ -124,7 +124,7 @@ namespace boost { namespace proto /// template<typename Tag, typename Fun> /// struct recurse_if_ /// : if_< - /// // If the current node has type type "Tag" ... + /// // If the current node has type "Tag" ... /// is_same<tag_of<_>, Tag>() /// // ... recurse, otherwise ... /// , reverse_fold<_, _state, recurse_if_<Tag, Fun> > diff --git a/boost/proto/transform/impl.hpp b/boost/proto/transform/impl.hpp index 80e9a624f0..5490086bd9 100644 --- a/boost/proto/transform/impl.hpp +++ b/boost/proto/transform/impl.hpp @@ -10,16 +10,72 @@ #define BOOST_PROTO_TRANSFORM_IMPL_HPP_EAN_04_03_2008 #include <boost/config.hpp> +#include <boost/mpl/bool.hpp> +#include <boost/type_traits/add_const.hpp> +#include <boost/type_traits/add_reference.hpp> #include <boost/proto/proto_fwd.hpp> +#include <boost/proto/detail/any.hpp> +#include <boost/proto/detail/static_const.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif namespace boost { namespace proto { -#ifdef BOOST_NO_RVALUE_REFERENCES + namespace envns_ + { + //////////////////////////////////////////////////////////////////////////////////////////// + struct key_not_found + {}; + + //////////////////////////////////////////////////////////////////////////////////////////// + // empty_env + struct empty_env + { + typedef void proto_environment_; + + template<typename OtherTag, typename OtherValue = key_not_found> + struct lookup + { + typedef OtherValue type; + typedef + typename add_reference<typename add_const<OtherValue>::type>::type + const_reference; + }; + + key_not_found operator[](detail::any) const + { + return key_not_found(); + } + + template<typename T> + T const &at(detail::any, T const &t) const + { + return t; + } + }; + } + + //////////////////////////////////////////////////////////////////////////////////////////// + // is_env + template<typename T, typename Void> + struct is_env + : mpl::false_ + {}; + + template<typename T> + struct is_env<T, typename T::proto_environment_> + : mpl::true_ + {}; + + template<typename T> + struct is_env<T &, void> + : is_env<T> + {}; + +#ifdef BOOST_NO_CXX11_RVALUE_REFERENCES /// INTERNAL ONLY /// @@ -39,8 +95,19 @@ namespace boost { namespace proto typename boost::proto::detail::apply_transform<transform_type(Expr &)>::result_type \ operator ()(Expr &e) const \ { \ - int i = 0; \ - return boost::proto::detail::apply_transform<transform_type(Expr &)>()(e, i, i); \ + boost::proto::empty_state s = 0; \ + boost::proto::empty_env d; \ + return boost::proto::detail::apply_transform<transform_type(Expr &)>()(e, s, d); \ + } \ + \ + template<typename Expr> \ + BOOST_FORCEINLINE \ + typename boost::proto::detail::apply_transform<transform_type(Expr const &)>::result_type \ + operator ()(Expr const &e) const \ + { \ + boost::proto::empty_state s = 0; \ + boost::proto::empty_env d; \ + return boost::proto::detail::apply_transform<transform_type(Expr const &)>()(e, s, d); \ } \ \ template<typename Expr, typename State> \ @@ -48,8 +115,17 @@ namespace boost { namespace proto typename boost::proto::detail::apply_transform<transform_type(Expr &, State &)>::result_type \ operator ()(Expr &e, State &s) const \ { \ - int i = 0; \ - return boost::proto::detail::apply_transform<transform_type(Expr &, State &)>()(e, s, i); \ + boost::proto::empty_env d; \ + return boost::proto::detail::apply_transform<transform_type(Expr &, State &)>()(e, s, d); \ + } \ + \ + template<typename Expr, typename State> \ + BOOST_FORCEINLINE \ + typename boost::proto::detail::apply_transform<transform_type(Expr const &, State &)>::result_type \ + operator ()(Expr const &e, State &s) const \ + { \ + boost::proto::empty_env d; \ + return boost::proto::detail::apply_transform<transform_type(Expr const &, State &)>()(e, s, d); \ } \ \ template<typename Expr, typename State> \ @@ -57,8 +133,17 @@ namespace boost { namespace proto typename boost::proto::detail::apply_transform<transform_type(Expr &, State const &)>::result_type \ operator ()(Expr &e, State const &s) const \ { \ - int i = 0; \ - return boost::proto::detail::apply_transform<transform_type(Expr &, State const &)>()(e, s, i); \ + boost::proto::empty_env d; \ + return boost::proto::detail::apply_transform<transform_type(Expr &, State const &)>()(e, s, d); \ + } \ + \ + template<typename Expr, typename State> \ + BOOST_FORCEINLINE \ + typename boost::proto::detail::apply_transform<transform_type(Expr const &, State const &)>::result_type \ + operator ()(Expr const &e, State const &s) const \ + { \ + boost::proto::empty_env d; \ + return boost::proto::detail::apply_transform<transform_type(Expr const &, State const &)>()(e, s, d); \ } \ \ template<typename Expr, typename State, typename Data> \ @@ -71,11 +156,27 @@ namespace boost { namespace proto \ template<typename Expr, typename State, typename Data> \ BOOST_FORCEINLINE \ + typename boost::proto::detail::apply_transform<transform_type(Expr const &, State &, Data &)>::result_type \ + operator ()(Expr const &e, State &s, Data &d) const \ + { \ + return boost::proto::detail::apply_transform<transform_type(Expr const &, State &, Data &)>()(e, s, d); \ + } \ + \ + template<typename Expr, typename State, typename Data> \ + BOOST_FORCEINLINE \ typename boost::proto::detail::apply_transform<transform_type(Expr &, State const &, Data &)>::result_type \ operator ()(Expr &e, State const &s, Data &d) const \ { \ return boost::proto::detail::apply_transform<transform_type(Expr &, State const &, Data &)>()(e, s, d); \ } \ + \ + template<typename Expr, typename State, typename Data> \ + BOOST_FORCEINLINE \ + typename boost::proto::detail::apply_transform<transform_type(Expr const &, State const &, Data &)>::result_type \ + operator ()(Expr const &e, State const &s, Data &d) const \ + { \ + return boost::proto::detail::apply_transform<transform_type(Expr const &, State const &, Data &)>()(e, s, d); \ + } \ /**/ #else @@ -98,8 +199,9 @@ namespace boost { namespace proto typename boost::proto::detail::apply_transform<transform_type(Expr const &)>::result_type \ operator ()(Expr &&e) const \ { \ - int i = 0; \ - return boost::proto::detail::apply_transform<transform_type(Expr const &)>()(e, i, i); \ + boost::proto::empty_state s = 0; \ + boost::proto::empty_env d; \ + return boost::proto::detail::apply_transform<transform_type(Expr const &)>()(e, s, d); \ } \ \ template<typename Expr, typename State> \ @@ -107,8 +209,8 @@ namespace boost { namespace proto typename boost::proto::detail::apply_transform<transform_type(Expr const &, State const &)>::result_type \ operator ()(Expr &&e, State &&s) const \ { \ - int i = 0; \ - return boost::proto::detail::apply_transform<transform_type(Expr const &, State const &)>()(e, s, i); \ + boost::proto::empty_env d; \ + return boost::proto::detail::apply_transform<transform_type(Expr const &, State const &)>()(e, s, d); \ } \ \ template<typename Expr, typename State, typename Data> \ @@ -133,12 +235,12 @@ namespace boost { namespace proto template<typename PrimitiveTransform, typename Expr> struct apply_transform<PrimitiveTransform(Expr)> - : PrimitiveTransform::template impl<Expr, int, int> + : PrimitiveTransform::template impl<Expr, empty_state, empty_env> {}; template<typename PrimitiveTransform, typename Expr, typename State> struct apply_transform<PrimitiveTransform(Expr, State)> - : PrimitiveTransform::template impl<Expr, State, int> + : PrimitiveTransform::template impl<Expr, State, empty_env> {}; template<typename PrimitiveTransform, typename Expr, typename State, typename Data> @@ -243,7 +345,7 @@ namespace boost { namespace proto }} // namespace boost::proto -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/transform/make.hpp b/boost/proto/transform/make.hpp index 1f183d9343..565254302d 100644 --- a/boost/proto/transform/make.hpp +++ b/boost/proto/transform/make.hpp @@ -33,7 +33,7 @@ #include <boost/proto/detail/as_lvalue.hpp> #include <boost/proto/detail/ignore_unused.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif @@ -100,7 +100,7 @@ namespace boost { namespace proto static bool const applied = true; }; - #if BOOST_WORKAROUND(__GNUC__, == 3) || (__GNUC__ == 4 && __GNUC_MINOR__ == 0) + #if BOOST_WORKAROUND(__GNUC__, == 3) || (BOOST_WORKAROUND(__GNUC__, == 4) && __GNUC_MINOR__ == 0) // work around GCC bug template<typename Tag, typename Args, long N, typename Expr, typename State, typename Data> struct make_if_<proto::expr<Tag, Args, N>, Expr, State, Data, false> @@ -277,7 +277,7 @@ namespace boost { namespace proto }} -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/transform/pass_through.hpp b/boost/proto/transform/pass_through.hpp index d53d15a840..bdd152e705 100644 --- a/boost/proto/transform/pass_through.hpp +++ b/boost/proto/transform/pass_through.hpp @@ -16,13 +16,15 @@ #include <boost/preprocessor/repetition/enum.hpp> #include <boost/preprocessor/iteration/iterate.hpp> #include <boost/mpl/bool.hpp> +#include <boost/mpl/if.hpp> +#include <boost/type_traits/is_same.hpp> #include <boost/type_traits/remove_reference.hpp> #include <boost/proto/proto_fwd.hpp> #include <boost/proto/args.hpp> #include <boost/proto/transform/impl.hpp> #include <boost/proto/detail/ignore_unused.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif @@ -33,6 +35,7 @@ namespace boost { namespace proto { template< typename Grammar + , typename Domain , typename Expr , typename State , typename Data @@ -43,8 +46,8 @@ namespace boost { namespace proto #include <boost/proto/transform/detail/pass_through_impl.hpp> - template<typename Grammar, typename Expr, typename State, typename Data> - struct pass_through_impl<Grammar, Expr, State, Data, 0> + template<typename Grammar, typename Domain, typename Expr, typename State, typename Data> + struct pass_through_impl<Grammar, Domain, Expr, State, Data, 0> : transform_impl<Expr, State, Data> { typedef Expr result_type; @@ -53,11 +56,7 @@ namespace boost { namespace proto /// \return \c e /// \throw nothrow BOOST_FORCEINLINE - #ifdef BOOST_PROTO_STRICT_RESULT_OF - result_type - #else - typename pass_through_impl::expr_param - #endif + BOOST_PROTO_RETURN_TYPE_STRICT_LOOSE(result_type, typename pass_through_impl::expr_param) operator()( typename pass_through_impl::expr_param e , typename pass_through_impl::state_param @@ -120,26 +119,26 @@ namespace boost { namespace proto /// > /// {}; /// \endcode - template<typename Grammar> + template<typename Grammar, typename Domain /* = deduce_domain*/> struct pass_through - : transform<pass_through<Grammar> > + : transform<pass_through<Grammar, Domain> > { template<typename Expr, typename State, typename Data> struct impl - : detail::pass_through_impl<Grammar, Expr, State, Data> + : detail::pass_through_impl<Grammar, Domain, Expr, State, Data> {}; }; /// INTERNAL ONLY /// - template<typename Grammar> - struct is_callable<pass_through<Grammar> > + template<typename Grammar, typename Domain> + struct is_callable<pass_through<Grammar, Domain> > : mpl::true_ {}; }} // namespace boost::proto -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif diff --git a/boost/proto/transform/when.hpp b/boost/proto/transform/when.hpp index bd4cb9fa6a..78ffa9e99d 100644 --- a/boost/proto/transform/when.hpp +++ b/boost/proto/transform/when.hpp @@ -16,13 +16,15 @@ #include <boost/mpl/at.hpp> #include <boost/mpl/if.hpp> #include <boost/mpl/map.hpp> +#include <boost/mpl/eval_if.hpp> #include <boost/proto/proto_fwd.hpp> #include <boost/proto/traits.hpp> #include <boost/proto/transform/call.hpp> #include <boost/proto/transform/make.hpp> #include <boost/proto/transform/impl.hpp> +#include <boost/proto/transform/env.hpp> -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(push) # pragma warning(disable : 4714) // function 'xxx' marked as __forceinline not inlined #endif @@ -155,6 +157,14 @@ namespace boost { namespace proto : when<_, Fun> {}; + namespace envns_ + { + // Define the transforms global + BOOST_PROTO_DEFINE_ENV_VAR(transforms_type, transforms); + } + + using envns_::transforms; + /// \brief This specialization uses the Data parameter as a collection /// of transforms that can be indexed by the specified rule. /// @@ -174,12 +184,13 @@ namespace boost { namespace proto template<typename Expr, typename State, typename Data> struct impl - : Data::template when<Grammar>::template impl<Expr, State, Data> - {}; - - template<typename Expr, typename State, typename Data> - struct impl<Expr, State, Data &> - : Data::template when<Grammar>::template impl<Expr, State, Data &> + : remove_reference< + typename mpl::eval_if_c< + proto::result_of::has_env_var<Data, transforms_type>::value + , proto::result_of::env_var<Data, transforms_type> + , proto::result_of::env_var<Data, data_type> + >::type + >::type::template when<Grammar>::template impl<Expr, State, Data> {}; }; @@ -249,7 +260,7 @@ namespace boost { namespace proto }} // namespace boost::proto -#if defined(_MSC_VER) && (_MSC_VER >= 1020) +#if defined(_MSC_VER) # pragma warning(pop) #endif |