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 const> { typedef T const& type; };
// remove_const< remove_reference<_> >
template <typename T> struct uncr { typedef T type; };
template <typename T> struct uncr<T const> { typedef T type; };
template <typename T> struct uncr<T &> { typedef T type; };
template <typename T> struct uncr<T const &> { typedef T type; };
// appropriately qualified target function in const context
template <typename T> struct qf_c { typedef T const type; };
template <typename T> struct qf_c<T const> { typedef T const type; };
template <typename T> struct qf_c<T &> { 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

View File

@ -11,7 +11,7 @@
#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>
namespace boost { namespace fusion
@ -25,8 +25,8 @@ namespace boost { namespace fusion
{
Function fnc_transformed;
typedef typename boost::add_reference<Function>::type func_fwd_t;
typedef typename detail::call_param<Function>::type func_const_fwd_t;
typedef typename detail::qf_c<Function>::type & func_const_fwd_t;
typedef typename detail::qf<Function>::type & func_fwd_t;
public:

View File

@ -11,7 +11,7 @@
#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>
namespace boost { namespace fusion
@ -25,8 +25,8 @@ namespace boost { namespace fusion
{
Function fnc_transformed;
typedef typename boost::add_reference<Function>::type func_fwd_t;
typedef typename detail::call_param<Function>::type func_const_fwd_t;
typedef typename detail::qf_c<Function>::type & func_const_fwd_t;
typedef typename detail::qf<Function>::type & func_fwd_t;
public:

View File

@ -11,7 +11,7 @@
#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>
namespace boost { namespace fusion
@ -25,8 +25,8 @@ namespace boost { namespace fusion
{
Function fnc_transformed;
typedef typename boost::add_reference<Function>::type func_fwd_t;
typedef typename detail::call_param<Function>::type func_const_fwd_t;
typedef typename detail::qf_c<Function>::type & func_const_fwd_t;
typedef typename detail::qf<Function>::type & func_fwd_t;
public:

View File

@ -37,7 +37,9 @@ namespace boost { namespace fusion
{
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;
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 <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 \
operator()(params) const \
{ \
@ -127,7 +129,7 @@ namespace boost
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename 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,
typename detail::gref<T,>::type BOOST_PP_INTERCEPT) > & )>
{ };
@ -143,7 +145,7 @@ namespace boost
#if BOOST_WORKAROUND(BOOST_MSVC,BOOST_TESTED_AT(1400))
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
operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,PT,a)) const
{

View File

@ -32,7 +32,9 @@ namespace boost { namespace fusion
{
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;
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
{
@ -95,7 +97,7 @@ namespace boost
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename 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,
typename detail::mref<T,>::type BOOST_PP_INTERCEPT) > & )>
{ };
@ -108,7 +110,7 @@ namespace boost
{ };
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
operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,& a)) const
{

View File

@ -32,7 +32,9 @@ namespace boost { namespace fusion
{
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;
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
{
@ -95,7 +97,7 @@ namespace boost
template <class Self, BOOST_PP_ENUM_PARAMS(N,typename 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,
typename detail::cref<T,>::type BOOST_PP_INTERCEPT) > & )>
{ };
@ -108,7 +110,7 @@ namespace boost
{ };
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
operator()(BOOST_PP_ENUM_BINARY_PARAMS(N,T,const& a)) const
{

View File

@ -41,26 +41,29 @@ namespace boost { namespace fusion
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;
}
template <class Function, class Sequence>
class unfused_typed
: public detail::unfused_typed_impl
< unfused_typed<Function,Sequence>, typename detail::uncr<Function>::type,
Sequence, result_of::size<Sequence>::value >
< unfused_typed<Function,Sequence>, typename detail::qf_c<Function>::type,
typename detail::qf<Function>::type, Sequence, result_of::size<Sequence>::value >
{
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::unfused_typed_impl<
unfused_typed<Function,Sequence>,function,Sequence,
unfused_typed<Function,Sequence>,function_c,function,Sequence,
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;
public:
@ -75,21 +78,22 @@ namespace boost { namespace fusion
namespace detail
{
template <class Derived, class Function, class Sequence>
struct unfused_typed_impl<Derived,Function,Sequence,0>
template <class Derived, class FunctionC, class Function,
class Sequence>
struct unfused_typed_impl<Derived,FunctionC,Function,Sequence,0>
{
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 <class Derived, class Function, class Sequence>
struct unfused_typed_impl<Derived,Function,Sequence,N>
: unfused_typed_impl<Derived,Function,
template <class Derived, class FunctionC, class Function,
class Sequence>
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) >
{
typedef typename result_of::as_vector<Sequence>::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<Sequence>::type, BOOST_PP_DEC(N)
>::operator();
@ -164,7 +169,7 @@ namespace boost
typename call_param<typename result_of::value_at_c<s,i>::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));