From 50bd63adcdba1ca9dd32fccdb49bbc5fe0bc9082 Mon Sep 17 00:00:00 2001 From: Tobias Schwinger Date: Sun, 15 Jul 2007 16:25:11 +0000 Subject: [PATCH] fixes const-correctness [SVN r38222] --- .../functional/adapter/detail/access.hpp | 14 ++++--- .../boost/fusion/functional/adapter/fused.hpp | 6 +-- .../adapter/fused_function_object.hpp | 6 +-- .../functional/adapter/fused_procedure.hpp | 6 +-- .../functional/adapter/unfused_generic.hpp | 14 ++++--- .../adapter/unfused_lvalue_args.hpp | 14 ++++--- .../adapter/unfused_rvalue_args.hpp | 14 ++++--- .../functional/adapter/unfused_typed.hpp | 39 +++++++++++-------- 8 files changed, 64 insertions(+), 49 deletions(-) diff --git a/include/boost/fusion/functional/adapter/detail/access.hpp b/include/boost/fusion/functional/adapter/detail/access.hpp index 2e1f075b..ee03ffd0 100644 --- a/include/boost/fusion/functional/adapter/detail/access.hpp +++ b/include/boost/fusion/functional/adapter/detail/access.hpp @@ -26,11 +26,15 @@ namespace boost { namespace fusion { namespace detail template struct gref { typedef T & type; }; template struct gref { typedef T const& type; }; - // remove_const< remove_reference<_> > - template struct uncr { typedef T type; }; - template struct uncr { typedef T type; }; - template struct uncr { typedef T type; }; - template struct uncr { typedef T type; }; + // appropriately qualified target function in const context + template struct qf_c { typedef T const type; }; + template struct qf_c { typedef T const type; }; + template struct qf_c { typedef T type; }; + + // appropriately qualified target function in non-const context + template struct qf { typedef T type; }; + template struct qf { typedef T const type; }; + template struct qf { typedef T type; }; }}} #endif diff --git a/include/boost/fusion/functional/adapter/fused.hpp b/include/boost/fusion/functional/adapter/fused.hpp index 78ddf2ef..08e8897a 100644 --- a/include/boost/fusion/functional/adapter/fused.hpp +++ b/include/boost/fusion/functional/adapter/fused.hpp @@ -11,7 +11,7 @@ #include -#include +#include #include namespace boost { namespace fusion @@ -25,8 +25,8 @@ namespace boost { namespace fusion { Function fnc_transformed; - typedef typename boost::add_reference::type func_fwd_t; - typedef typename detail::call_param::type func_const_fwd_t; + typedef typename detail::qf_c::type & func_const_fwd_t; + typedef typename detail::qf::type & func_fwd_t; public: diff --git a/include/boost/fusion/functional/adapter/fused_function_object.hpp b/include/boost/fusion/functional/adapter/fused_function_object.hpp index 600d3a9a..12cd1e27 100644 --- a/include/boost/fusion/functional/adapter/fused_function_object.hpp +++ b/include/boost/fusion/functional/adapter/fused_function_object.hpp @@ -11,7 +11,7 @@ #include -#include +#include #include namespace boost { namespace fusion @@ -25,8 +25,8 @@ namespace boost { namespace fusion { Function fnc_transformed; - typedef typename boost::add_reference::type func_fwd_t; - typedef typename detail::call_param::type func_const_fwd_t; + typedef typename detail::qf_c::type & func_const_fwd_t; + typedef typename detail::qf::type & func_fwd_t; public: diff --git a/include/boost/fusion/functional/adapter/fused_procedure.hpp b/include/boost/fusion/functional/adapter/fused_procedure.hpp index f0f8bac4..78034b97 100644 --- a/include/boost/fusion/functional/adapter/fused_procedure.hpp +++ b/include/boost/fusion/functional/adapter/fused_procedure.hpp @@ -11,7 +11,7 @@ #include -#include +#include #include namespace boost { namespace fusion @@ -25,8 +25,8 @@ namespace boost { namespace fusion { Function fnc_transformed; - typedef typename boost::add_reference::type func_fwd_t; - typedef typename detail::call_param::type func_const_fwd_t; + typedef typename detail::qf_c::type & func_const_fwd_t; + typedef typename detail::qf::type & func_fwd_t; public: diff --git a/include/boost/fusion/functional/adapter/unfused_generic.hpp b/include/boost/fusion/functional/adapter/unfused_generic.hpp index b687e4ad..f609ab49 100644 --- a/include/boost/fusion/functional/adapter/unfused_generic.hpp +++ b/include/boost/fusion/functional/adapter/unfused_generic.hpp @@ -37,7 +37,9 @@ namespace boost { namespace fusion { Function fnc_transformed; - typedef typename detail::uncr::type function; + typedef typename detail::qf_c::type function_c; + typedef typename detail::qf::type function; + typedef typename detail::call_param::type func_const_fwd_t; public: @@ -50,7 +52,7 @@ namespace boost { namespace fusion struct result; typedef typename boost::result_of< - function const (fusion::vector0 &) >::type call_const_0_result; + function_c(fusion::vector0 &) >::type call_const_0_result; inline call_const_0_result operator()() const { @@ -69,7 +71,7 @@ namespace boost { namespace fusion #define BOOST_FUSION_CODE(tpl_params,arg_types,params,args) \ template \ - inline typename boost::result_of & )>::type \ operator()(params) const \ { \ @@ -127,7 +129,7 @@ namespace boost template struct result < Self const (BOOST_PP_ENUM_PARAMS(N,T)) > - : boost::result_of::type BOOST_PP_INTERCEPT) > & )> { }; @@ -135,7 +137,7 @@ namespace boost template struct result < Self(BOOST_PP_ENUM_PARAMS(N,T)) > - : boost::result_of::type BOOST_PP_INTERCEPT) > & )> { }; @@ -143,7 +145,7 @@ namespace boost #if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400)) template - inline typename boost::result_of & )>::type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,PT,a)) const { diff --git a/include/boost/fusion/functional/adapter/unfused_lvalue_args.hpp b/include/boost/fusion/functional/adapter/unfused_lvalue_args.hpp index 93841a64..7b801cf7 100644 --- a/include/boost/fusion/functional/adapter/unfused_lvalue_args.hpp +++ b/include/boost/fusion/functional/adapter/unfused_lvalue_args.hpp @@ -32,7 +32,9 @@ namespace boost { namespace fusion { Function fnc_transformed; - typedef typename detail::uncr::type function; + typedef typename detail::qf_c::type function_c; + typedef typename detail::qf::type function; + typedef typename detail::call_param::type func_const_fwd_t; public: @@ -45,7 +47,7 @@ namespace boost { namespace fusion struct result; typedef typename boost::result_of< - function const (fusion::vector0 &) >::type call_const_0_result; + function_c(fusion::vector0 &) >::type call_const_0_result; inline call_const_0_result operator()() const { @@ -54,7 +56,7 @@ namespace boost { namespace fusion } typedef typename boost::result_of< - function (fusion::vector0 &) >::type call_0_result; + function(fusion::vector0 &) >::type call_0_result; inline call_0_result operator()() { @@ -95,20 +97,20 @@ namespace boost template struct result< Self const (BOOST_PP_ENUM_PARAMS(N,T)) > - : boost::result_of< function const ( + : boost::result_of< function_c( BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N, typename detail::mref::type BOOST_PP_INTERCEPT) > & )> { }; template struct result< Self(BOOST_PP_ENUM_PARAMS(N,T)) > - : boost::result_of< function ( + : boost::result_of< function( BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N, typename detail::mref::type BOOST_PP_INTERCEPT) > & )> { }; template - inline typename boost::result_of & )>::type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a)) const { diff --git a/include/boost/fusion/functional/adapter/unfused_rvalue_args.hpp b/include/boost/fusion/functional/adapter/unfused_rvalue_args.hpp index 26afd539..eea0fec9 100644 --- a/include/boost/fusion/functional/adapter/unfused_rvalue_args.hpp +++ b/include/boost/fusion/functional/adapter/unfused_rvalue_args.hpp @@ -32,7 +32,9 @@ namespace boost { namespace fusion { Function fnc_transformed; - typedef typename detail::uncr::type function; + typedef typename detail::qf_c::type function_c; + typedef typename detail::qf::type function; + typedef typename detail::call_param::type func_const_fwd_t; public: @@ -45,7 +47,7 @@ namespace boost { namespace fusion struct result; typedef typename boost::result_of< - function const (fusion::vector0 &) >::type call_const_0_result; + function_c(fusion::vector0 &) >::type call_const_0_result; inline call_const_0_result operator()() const { @@ -54,7 +56,7 @@ namespace boost { namespace fusion } typedef typename boost::result_of< - function (fusion::vector0 &) >::type call_0_result; + function(fusion::vector0 &) >::type call_0_result; inline call_0_result operator()() { @@ -95,20 +97,20 @@ namespace boost template struct result< Self const (BOOST_PP_ENUM_PARAMS(N,T)) > - : boost::result_of< function const ( + : boost::result_of< function_c( BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N, typename detail::cref::type BOOST_PP_INTERCEPT) > & )> { }; template struct result< Self (BOOST_PP_ENUM_PARAMS(N,T)) > - : boost::result_of< function ( + : boost::result_of< function( BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N, typename detail::cref::type BOOST_PP_INTERCEPT) > & )> { }; template - inline typename boost::result_of & )>::type operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const& a)) const { diff --git a/include/boost/fusion/functional/adapter/unfused_typed.hpp b/include/boost/fusion/functional/adapter/unfused_typed.hpp index e892bd9a..3b463569 100644 --- a/include/boost/fusion/functional/adapter/unfused_typed.hpp +++ b/include/boost/fusion/functional/adapter/unfused_typed.hpp @@ -41,26 +41,29 @@ namespace boost { namespace fusion namespace detail { - template + template struct unfused_typed_impl; } template class unfused_typed : public detail::unfused_typed_impl - < unfused_typed, typename detail::uncr::type, - Sequence, result_of::size::value > + < unfused_typed, typename detail::qf_c::type, + typename detail::qf::type, Sequence, result_of::size::value > { Function fnc_transformed; - typedef typename detail::uncr::type function; + typedef typename detail::qf_c::type function_c; + typedef typename detail::qf::type function; + typedef typename detail::call_param::type func_const_fwd_t; typedef typename detail::unfused_typed_impl< - unfused_typed,function,Sequence, + unfused_typed,function_c,function,Sequence, result_of::size::value > base; - template + template friend struct detail::unfused_typed_impl; public: @@ -75,21 +78,22 @@ namespace boost { namespace fusion namespace detail { - template - struct unfused_typed_impl + template + struct unfused_typed_impl { typedef fusion::vector0 arg_vector_t; public: typedef typename boost::result_of< - Function const (arg_vector_t &) > call_const_0_result; + FunctionC (arg_vector_t &) > call_const_0_result; typedef typename boost::result_of< Function(arg_vector_t &) > call_0_result; inline typename boost::result_of< - Function const (arg_vector_t &) >::type + FunctionC (arg_vector_t &) >::type operator()() const { arg_vector_t arg; @@ -139,9 +143,10 @@ namespace boost namespace detail { - template - struct unfused_typed_impl - : unfused_typed_impl + struct unfused_typed_impl + : unfused_typed_impl::type, BOOST_PP_DEC(N) > { typedef typename result_of::as_vector::type arg_vector_t; @@ -149,14 +154,14 @@ namespace boost protected: typedef typename boost::result_of< - Function const (arg_vector_t &) > BOOST_PP_CAT(rc,N); + FunctionC(arg_vector_t &) > BOOST_PP_CAT(rc,N); typedef typename boost::result_of< Function(arg_vector_t &) > BOOST_PP_CAT(r,N); public: - using unfused_typed_impl< Derived,Function, + using unfused_typed_impl< Derived,FunctionC,Function, typename result_of::pop_back::type, BOOST_PP_DEC(N) >::operator(); @@ -164,7 +169,7 @@ namespace boost typename call_param::type>::type a##i inline typename boost::result_of< - Function const (arg_vector_t &) >::type + FunctionC(arg_vector_t &) >::type operator()(BOOST_PP_ENUM(N,M,arg_vector_t)) const { arg_vector_t arg(BOOST_PP_ENUM_PARAMS(N,a)); @@ -173,7 +178,7 @@ namespace boost #if !BOOST_WORKAROUND(BOOST_MSVC, < 1400) inline typename boost::result_of< - Function (arg_vector_t &) >::type + Function(arg_vector_t &) >::type operator()(BOOST_PP_ENUM(N,M,arg_vector_t)) { arg_vector_t arg(BOOST_PP_ENUM_PARAMS(N,a));