|
Boost Users : |
Subject: [Boost-users] fusion::result_of::invoke_function_object and references
From: Mike Tegtmeyer (tegtmeye_at_[hidden])
Date: 2009-06-26 17:48:05
I have another question regarding compilation failures with fusion. If
this has been discussed before, can someone please point me to the right
location. If not...
Is there some reason the application of result_of::invoke_function_object
fails to compile for sequence argument references?
ie: result_of::invoke_function_object<doit, fusion::vector<int>&>::type
Digging a little, it seems that the failure is due to the size<> operator
doesn't work with reference types (or is expecting the reference to be
stripped prior to this point). I understand that to avoid unnecessary
copies, tiers are typically used but in the case where chains of
invoke_function_object would like to be strung together where there is an
assignment or construction from the actual return value to a variable
declared as the type obtained from result_of (in a fold for example), it
seems that the vector copy is unavoidable (at least in my reading) unless
the argument vector is a const reference.
Is this an oversight or am I missing something?
Basically I am trying to string together N function objects in the
sequence where the ith object gets called with the result of the i-1th
object (where each has a different argument list) using fold and I am
running into extraneous copies of the return value. I can post a full
example if needed.
Thanks in advance,
Mike
error message:
/opt/local/include/boost/fusion/sequence/intrinsic/size.hpp:28: error:
const boost::fusion::vector<int, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_, boost::fusion::void_,
boost::fusion::void_, boost::fusion::void_>& is not a class, struct, or
union type
See code below.
#include <boost/fusion/container/vector.hpp>
#include <boost/fusion/functional/invocation/invoke_function_object.hpp>
namespace b = boost;
namespace bf = boost::fusion;
struct doit {
template <typename Sig>
struct result;
template <typename Self, typename T>
struct result< Self(const T &) >
{
typedef int type;
};
template <typename T>
int operator()(const T &t) const
{
return 1;
}
};
#if !OK
typedef bf::result_of::
invoke_function_object<doit,const bf::vector<int>&>::type
result_type2;
#else
typedef bf::result_of::
invoke_function_object<doit,const bf::vector<int> >::type
result_type2;
#endif
int main() {return 0;}
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net