fixes const-correctness

[SVN r38222]
This commit is contained in:
Tobias Schwinger
2007-07-15 16:25:11 +00:00
parent 76bb8db5b7
commit 50bd63adcd
8 changed files with 64 additions and 49 deletions

View File

@ -26,11 +26,15 @@ namespace boost { namespace fusion { namespace detail
template <typename T> struct gref<T&> { typedef T & type; }; template <typename T> struct gref<T&> { typedef T & type; };
template <typename T> struct gref<T const> { typedef T const& type; }; template <typename T> struct gref<T const> { typedef T const& type; };
// remove_const< remove_reference<_> > // appropriately qualified target function in const context
template <typename T> struct uncr { typedef T type; }; template <typename T> struct qf_c { typedef T const type; };
template <typename T> struct uncr<T const> { typedef T type; }; template <typename T> struct qf_c<T const> { typedef T const type; };
template <typename T> struct uncr<T &> { typedef T type; }; template <typename T> struct qf_c<T &> { typedef T type; };
template <typename T> struct uncr<T const &> { typedef T type; };
// appropriately qualified target function in non-const context
template <typename T> struct qf { typedef T type; };
template <typename T> struct qf<T const> { typedef T const type; };
template <typename T> struct qf<T &> { typedef T type; };
}}} }}}
#endif #endif

View File

@ -11,7 +11,7 @@
#include <boost/type_traits/add_reference.hpp> #include <boost/type_traits/add_reference.hpp>
#include <boost/fusion/support/detail/access.hpp> #include <boost/fusion/functional/adapter/detail/access.hpp>
#include <boost/fusion/functional/invocation/invoke.hpp> #include <boost/fusion/functional/invocation/invoke.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
@ -25,8 +25,8 @@ namespace boost { namespace fusion
{ {
Function fnc_transformed; Function fnc_transformed;
typedef typename boost::add_reference<Function>::type func_fwd_t; typedef typename detail::qf_c<Function>::type & func_const_fwd_t;
typedef typename detail::call_param<Function>::type func_const_fwd_t; typedef typename detail::qf<Function>::type & func_fwd_t;
public: public:

View File

@ -11,7 +11,7 @@
#include <boost/type_traits/add_reference.hpp> #include <boost/type_traits/add_reference.hpp>
#include <boost/fusion/support/detail/access.hpp> #include <boost/fusion/functional/adapter/detail/access.hpp>
#include <boost/fusion/functional/invocation/invoke_function_object.hpp> #include <boost/fusion/functional/invocation/invoke_function_object.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
@ -25,8 +25,8 @@ namespace boost { namespace fusion
{ {
Function fnc_transformed; Function fnc_transformed;
typedef typename boost::add_reference<Function>::type func_fwd_t; typedef typename detail::qf_c<Function>::type & func_const_fwd_t;
typedef typename detail::call_param<Function>::type func_const_fwd_t; typedef typename detail::qf<Function>::type & func_fwd_t;
public: public:

View File

@ -11,7 +11,7 @@
#include <boost/type_traits/add_reference.hpp> #include <boost/type_traits/add_reference.hpp>
#include <boost/fusion/support/detail/access.hpp> #include <boost/fusion/functional/adapter/detail/access.hpp>
#include <boost/fusion/functional/invocation/invoke_procedure.hpp> #include <boost/fusion/functional/invocation/invoke_procedure.hpp>
namespace boost { namespace fusion namespace boost { namespace fusion
@ -25,8 +25,8 @@ namespace boost { namespace fusion
{ {
Function fnc_transformed; Function fnc_transformed;
typedef typename boost::add_reference<Function>::type func_fwd_t; typedef typename detail::qf_c<Function>::type & func_const_fwd_t;
typedef typename detail::call_param<Function>::type func_const_fwd_t; typedef typename detail::qf<Function>::type & func_fwd_t;
public: public:

View File

@ -37,7 +37,9 @@ namespace boost { namespace fusion
{ {
Function fnc_transformed; Function fnc_transformed;
typedef typename detail::uncr<Function>::type function; typedef typename detail::qf_c<Function>::type function_c;
typedef typename detail::qf<Function>::type function;
typedef typename detail::call_param<Function>::type func_const_fwd_t; typedef typename detail::call_param<Function>::type func_const_fwd_t;
public: public:
@ -50,7 +52,7 @@ namespace boost { namespace fusion
struct result; struct result;
typedef typename boost::result_of< 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 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) \ #define BOOST_FUSION_CODE(tpl_params,arg_types,params,args) \
template <tpl_params> \ template <tpl_params> \
inline typename boost::result_of<function const ( \ inline typename boost::result_of<function_c( \
BOOST_PP_CAT(fusion::vector,N)<arg_types> & )>::type \ BOOST_PP_CAT(fusion::vector,N)<arg_types> & )>::type \
operator()(params) const \ operator()(params) const \
{ \ { \
@ -127,7 +129,7 @@ namespace boost
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)> template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
struct result struct result
< Self const (BOOST_PP_ENUM_PARAMS(N,T)) > < 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, BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
typename detail::gref<T,>::type BOOST_PP_INTERCEPT) > & )> typename detail::gref<T,>::type BOOST_PP_INTERCEPT) > & )>
{ }; { };
@ -135,7 +137,7 @@ namespace boost
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)> template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
struct result struct result
< Self(BOOST_PP_ENUM_PARAMS(N,T)) > < 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, BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
typename detail::gref<T,>::type BOOST_PP_INTERCEPT) > & )> typename detail::gref<T,>::type BOOST_PP_INTERCEPT) > & )>
{ }; { };
@ -143,7 +145,7 @@ namespace boost
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400)) #if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
template <BOOST_PP_ENUM_PARAMS(N,typename T)> template <BOOST_PP_ENUM_PARAMS(N,typename T)>
inline typename boost::result_of<function const( inline typename boost::result_of<function_c(
BOOST_PP_CAT(fusion::vector,N)<BOOST_PP_ENUM_PARAMS(N,PT)> & )>::type BOOST_PP_CAT(fusion::vector,N)<BOOST_PP_ENUM_PARAMS(N,PT)> & )>::type
operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,PT,a)) const operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,PT,a)) const
{ {

View File

@ -32,7 +32,9 @@ namespace boost { namespace fusion
{ {
Function fnc_transformed; Function fnc_transformed;
typedef typename detail::uncr<Function>::type function; typedef typename detail::qf_c<Function>::type function_c;
typedef typename detail::qf<Function>::type function;
typedef typename detail::call_param<Function>::type func_const_fwd_t; typedef typename detail::call_param<Function>::type func_const_fwd_t;
public: public:
@ -45,7 +47,7 @@ namespace boost { namespace fusion
struct result; struct result;
typedef typename boost::result_of< 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 inline call_const_0_result operator()() const
{ {
@ -54,7 +56,7 @@ namespace boost { namespace fusion
} }
typedef typename boost::result_of< typedef typename boost::result_of<
function (fusion::vector0 &) >::type call_0_result; function(fusion::vector0 &) >::type call_0_result;
inline call_0_result operator()() inline call_0_result operator()()
{ {
@ -95,20 +97,20 @@ namespace boost
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)> template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
struct result< Self const (BOOST_PP_ENUM_PARAMS(N,T)) > 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, BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
typename detail::mref<T,>::type BOOST_PP_INTERCEPT) > & )> typename detail::mref<T,>::type BOOST_PP_INTERCEPT) > & )>
{ }; { };
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)> template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
struct result< Self(BOOST_PP_ENUM_PARAMS(N,T)) > 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, BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
typename detail::mref<T,>::type BOOST_PP_INTERCEPT) > & )> typename detail::mref<T,>::type BOOST_PP_INTERCEPT) > & )>
{ }; { };
template <BOOST_PP_ENUM_PARAMS(N,typename T)> template <BOOST_PP_ENUM_PARAMS(N,typename T)>
inline typename boost::result_of<function(BOOST_PP_CAT(fusion::vector,N) inline typename boost::result_of<function_c(BOOST_PP_CAT(fusion::vector,N)
<BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT)> & )>::type <BOOST_PP_ENUM_BINARY_PARAMS(N,T,& BOOST_PP_INTERCEPT)> & )>::type
operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a)) const operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a)) const
{ {

View File

@ -32,7 +32,9 @@ namespace boost { namespace fusion
{ {
Function fnc_transformed; Function fnc_transformed;
typedef typename detail::uncr<Function>::type function; typedef typename detail::qf_c<Function>::type function_c;
typedef typename detail::qf<Function>::type function;
typedef typename detail::call_param<Function>::type func_const_fwd_t; typedef typename detail::call_param<Function>::type func_const_fwd_t;
public: public:
@ -45,7 +47,7 @@ namespace boost { namespace fusion
struct result; struct result;
typedef typename boost::result_of< 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 inline call_const_0_result operator()() const
{ {
@ -54,7 +56,7 @@ namespace boost { namespace fusion
} }
typedef typename boost::result_of< typedef typename boost::result_of<
function (fusion::vector0 &) >::type call_0_result; function(fusion::vector0 &) >::type call_0_result;
inline call_0_result operator()() inline call_0_result operator()()
{ {
@ -95,20 +97,20 @@ namespace boost
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)> template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
struct result< Self const (BOOST_PP_ENUM_PARAMS(N,T)) > 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, BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
typename detail::cref<T,>::type BOOST_PP_INTERCEPT) > & )> typename detail::cref<T,>::type BOOST_PP_INTERCEPT) > & )>
{ }; { };
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)> template <class Self, BOOST_PP_ENUM_PARAMS(N,typename T)>
struct result< Self (BOOST_PP_ENUM_PARAMS(N,T)) > 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, BOOST_PP_CAT(fusion::vector,N)< BOOST_PP_ENUM_BINARY_PARAMS(N,
typename detail::cref<T,>::type BOOST_PP_INTERCEPT) > & )> typename detail::cref<T,>::type BOOST_PP_INTERCEPT) > & )>
{ }; { };
template <BOOST_PP_ENUM_PARAMS(N,typename T)> template <BOOST_PP_ENUM_PARAMS(N,typename T)>
inline typename boost::result_of<function(BOOST_PP_CAT(fusion::vector,N) inline typename boost::result_of<function_c(BOOST_PP_CAT(fusion::vector,N)
<BOOST_PP_ENUM_BINARY_PARAMS(N,T,const& BOOST_PP_INTERCEPT)> & )>::type <BOOST_PP_ENUM_BINARY_PARAMS(N,T,const& BOOST_PP_INTERCEPT)> & )>::type
operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const& a)) const operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const& a)) const
{ {

View File

@ -41,26 +41,29 @@ namespace boost { namespace fusion
namespace detail namespace detail
{ {
template <class Derived, class Function, class Sequence, long Arity> template <class Derived, class FunctionC, class Function,
class Sequence, long Arity>
struct unfused_typed_impl; struct unfused_typed_impl;
} }
template <class Function, class Sequence> template <class Function, class Sequence>
class unfused_typed class unfused_typed
: public detail::unfused_typed_impl : public detail::unfused_typed_impl
< unfused_typed<Function,Sequence>, typename detail::uncr<Function>::type, < unfused_typed<Function,Sequence>, typename detail::qf_c<Function>::type,
Sequence, result_of::size<Sequence>::value > typename detail::qf<Function>::type, Sequence, result_of::size<Sequence>::value >
{ {
Function fnc_transformed; Function fnc_transformed;
typedef typename detail::uncr<Function>::type function; typedef typename detail::qf_c<Function>::type function_c;
typedef typename detail::qf<Function>::type function;
typedef typename detail::call_param<Function>::type func_const_fwd_t; typedef typename detail::call_param<Function>::type func_const_fwd_t;
typedef typename detail::unfused_typed_impl< typedef typename detail::unfused_typed_impl<
unfused_typed<Function,Sequence>,function,Sequence, unfused_typed<Function,Sequence>,function_c,function,Sequence,
result_of::size<Sequence>::value > base; result_of::size<Sequence>::value > base;
template <class D, class F, class S, long A> template <class D, class FC, class F, class S, long A>
friend struct detail::unfused_typed_impl; friend struct detail::unfused_typed_impl;
public: public:
@ -75,21 +78,22 @@ namespace boost { namespace fusion
namespace detail namespace detail
{ {
template <class Derived, class Function, class Sequence> template <class Derived, class FunctionC, class Function,
struct unfused_typed_impl<Derived,Function,Sequence,0> class Sequence>
struct unfused_typed_impl<Derived,FunctionC,Function,Sequence,0>
{ {
typedef fusion::vector0 arg_vector_t; typedef fusion::vector0 arg_vector_t;
public: public:
typedef typename boost::result_of< 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< typedef typename boost::result_of<
Function(arg_vector_t &) > call_0_result; Function(arg_vector_t &) > call_0_result;
inline typename boost::result_of< inline typename boost::result_of<
Function const (arg_vector_t &) >::type FunctionC (arg_vector_t &) >::type
operator()() const operator()() const
{ {
arg_vector_t arg; arg_vector_t arg;
@ -139,9 +143,10 @@ namespace boost
namespace detail namespace detail
{ {
template <class Derived, class Function, class Sequence> template <class Derived, class FunctionC, class Function,
struct unfused_typed_impl<Derived,Function,Sequence,N> class Sequence>
: unfused_typed_impl<Derived,Function, struct unfused_typed_impl<Derived,FunctionC,Function,Sequence,N>
: unfused_typed_impl<Derived,FunctionC,Function,
typename result_of::pop_back<Sequence>::type, BOOST_PP_DEC(N) > typename result_of::pop_back<Sequence>::type, BOOST_PP_DEC(N) >
{ {
typedef typename result_of::as_vector<Sequence>::type arg_vector_t; typedef typename result_of::as_vector<Sequence>::type arg_vector_t;
@ -149,14 +154,14 @@ namespace boost
protected: protected:
typedef typename boost::result_of< 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< typedef typename boost::result_of<
Function(arg_vector_t &) > BOOST_PP_CAT(r,N); Function(arg_vector_t &) > BOOST_PP_CAT(r,N);
public: public:
using unfused_typed_impl< Derived,Function, using unfused_typed_impl< Derived,FunctionC,Function,
typename result_of::pop_back<Sequence>::type, BOOST_PP_DEC(N) typename result_of::pop_back<Sequence>::type, BOOST_PP_DEC(N)
>::operator(); >::operator();
@ -164,7 +169,7 @@ namespace boost
typename call_param<typename result_of::value_at_c<s,i>::type>::type a##i typename call_param<typename result_of::value_at_c<s,i>::type>::type a##i
inline typename boost::result_of< 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 operator()(BOOST_PP_ENUM(N,M,arg_vector_t)) const
{ {
arg_vector_t arg(BOOST_PP_ENUM_PARAMS(N,a)); arg_vector_t arg(BOOST_PP_ENUM_PARAMS(N,a));
@ -173,7 +178,7 @@ namespace boost
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1400) #if !BOOST_WORKAROUND(BOOST_MSVC, < 1400)
inline typename boost::result_of< inline typename boost::result_of<
Function (arg_vector_t &) >::type Function(arg_vector_t &) >::type
operator()(BOOST_PP_ENUM(N,M,arg_vector_t)) operator()(BOOST_PP_ENUM(N,M,arg_vector_t))
{ {
arg_vector_t arg(BOOST_PP_ENUM_PARAMS(N,a)); arg_vector_t arg(BOOST_PP_ENUM_PARAMS(N,a));