Larry Evans schrieb:
On 09/29/10 11:45, Larry Evans wrote:
[snip]
Using Christopher Schmidt's variadic fusion:
http://svn.boost.org/svn/boost/sandbox/SOC/2009/fusion/
solves problem.
Submitted bug:
https://svn.boost.org/trac/boost/ticket/4697
I am not sure whether this is an actual bug. Your problem boils down to
fusion::joint_view not supporting reference template type arguments. My
port changed that, but that's an entirely new feature that was
introduced to differentiate semantics for l- and rvalue sequences.
All inbuilt views of Fusion implicitly use references to underlying
*non-view* sequences. For example, in
typedef fusion::vector<...> t1;
typedef fusion::transform_view t2;
typedef fusion::joint_view t3;
t2 stores a reference to an instance of t1 and t3 stores a reference to
an instance to t1, but stores the underlying instance of t2 by value.
You can fix your example by removing the references to Lhs and Rhs
before passing down to Fusion:
namespace fold_join{struct join_ftor
{
template<typename Sig>
struct result;
template
struct result
{
typedef boost::fusion::joint_view<
typename boost::remove_reference<
Lhs
>::type,
typename boost::remove_reference<
Rhs
>::type
> type;
};
template
typename result::type
operator()(Lhs& lhs, Rhs& rhs)const
{
return boost::fusion::joint_view<
Lhs, Rhs
>(lhs,rhs);
}
};}
A few remarks:
You cannot use the function(!) fusion::join as it only accepts
const-qualified sequences. See
https://svn.boost.org/trac/boost/ticket/3954
for more information. The port has this 'fixed'. In your code you should
use fusion::joint_view directly.
It is definitely not a good idea to specialize boost::result_of with the
signature of your functor. You should stick to the official protocol,
that is defining a nested type 'result_type' or a nested template type
'result'. You should consider that the functor may be const- and/or even
reference-qualified (in c++11) when passed to the result metafunction.
See FCD 20.7.6.6 for more information.
template
typename boost::result_of::type
operator()(LhSequence& lhs, RhSequence& rhs)const
is not a good idea as well, as LhSequence and RhSequence in
join_ftor(LhSequence,RhSequence) loose cv-qualification.
-Christopher