Hi Eric,
When you access a member of a class template, it causes the template to
be instantiated. CanBeCalled cannot legally be instantiated with two
function types. Hence the error.
Function types? Are you really speaking of types of ordinary C++ functions? If so, I have to say that, by coincidence, I had not passed any function types at all. Or, am I missing anything here?
Also, proto::if_ takes as it's template parameter a Transform. It should
be a transform that evaluates to a compile-time Boolean.
So, this problem can simply be solved by replacing the '::type' part in my code with '()' in CanBeCalled<...>() even despite the fact that I never designed my CanBeCalled<> to be a transform?
You can easily solve both problems by making the parameter to if_ an
ObjectTransform, as follows:
<snip>
Unfortunately, this didn't quite help. Despite the fact that EmtnShiftFObjGram itself does compile, GCC 4.5.1 (under MinGW32, WinXP, SP3) fails to compile all the code I like. Here are my test cases, where the line annotated with *** doesn't compile. The error message I get can be found in the PS:
struct Plus1
{
double operator () (double d) const {return d + 1;}
};
struct Plus2
{
double operator () (double d1, double d2) const {return d1 + d2;}
};
double plus1(double d) {return d + 1;}
double plus2(double d1, double d2) {return d1 + d2;}
int main()
{
EW1() >> &plus1;
EW1() >> Plus1();
(EW1() ||
EW1()) >> Plus2();//***
(EW1() ||
EW1()) >> &plus2;
return 0;
}
Any idea now?
TIA,
--Hossein
P.S.
In file included from boost_1_42_0/boost/proto/core.hpp:22:0,
from boost_1_42_0/boost/proto/proto.hpp:12,
from EmtnGram.hpp:4,
from main.cpp:5:
boost_1_42_0/boost/proto/matches.hpp: In instantiation of 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::if_), EmtnTermOrGram(boost::proto::_child_c<0>)>()> >':
boost_1_42_0/boost/proto/matches.hpp:935:13: instantiated from 'boost::proto::detail::and_2&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::if_), EmtnTermOrGram(boost::proto::_child_c<0>)>()> > >'
boost_1_42_0/boost/proto/matches.hpp:994:13: instantiated from 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::and_boost::proto::wildcardns_::_ >, boost::proto::control::if_),
EmtnTermOrGram(boost::proto::_child_c<0>)>()> > >'
boost_1_42_0/boost/proto/matches.hpp:960:13: instantiated from 'boost::proto::detail::or_2&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::when()>, boost::proto::when()> >'
boost_1_42_0/boost/proto/matches.hpp:968:13: instantiated from 'boost::proto::detail::or_3&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::whenboost::proto::wildcardns_::_, boost::proto::control::if_boost::proto::_value()> >, mpl_::int_<1>()>, boost::proto::when()>,
boost::proto::when()> >'
boost_1_42_0/boost/proto/matches.hpp:968:13: instantiated from 'boost::proto::detail::or_4&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::when, boost::mpl::plus), EmtnTermOrGram(boost::proto::_child_c<1>)>()>,
boost::proto::whenboost::proto::wildcardns_::_, boost::proto::control::if_boost::proto::_value()> >, mpl_::int_<1>()>, boost::proto::when()>, boost::proto::when()> >'
boost_1_42_0/boost/proto/matches.hpp:985:13: instantiated from 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::or_, boost::mpl::plus), EmtnTermOrGram(boost::proto::_child_c<1>)>()>,
boost::proto::whenboost::proto::wildcardns_::_, boost::proto::control::if_boost::proto::_value()> >, mpl_::int_<1>()>, boost::proto::when()>, boost::proto::when()> > >'
boost_1_42_0/boost/proto/matches.hpp:985:13: instantiated from 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::or_ >'
boost_1_42_0/boost/proto/matches.hpp:505:13: instantiated from 'boost::proto::result_of::matches&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, EmotionGram>'
boost_1_42_0/boost/proto/operators.hpp:77:9: instantiated from 'boost::proto::detail::generate_if_left&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, boost::proto::exprns_::expr, 0l> >'
boost_1_42_0/boost/proto/operators.hpp:115:9: instantiated from 'boost::proto::detail::as_expr_if2&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, Plus2, void, void>'
boost_1_42_0/boost/proto/operators.hpp:154:9: instantiated from 'boost::proto::detail::as_expr_if&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, Plus2, void, void>'
main.cpp:33:86: instantiated from here
boost_1_42_0/boost/proto/matches.hpp:391:13: error: invalid use of incomplete type 'struct boost::proto::detail::uncvref > >::type'
Arity.hpp:76:9: error: declaration of 'struct boost::proto::detail::uncvref > >::type'
In file included from boost_1_42_0/boost/preprocessor/iteration/detail/iter/forward1.hpp:57:0,
from boost_1_42_0/boost/proto/matches.hpp:367,
from boost_1_42_0/boost/proto/core.hpp:22,
from boost_1_42_0/boost/proto/proto.hpp:12,
from EmtnGram.hpp:4,
from main.cpp:5:
boost_1_42_0/boost/proto/matches.hpp: In instantiation of 'boost::proto::detail::and_2&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::if_), EmtnTermOrGram(boost::proto::_child_c<0>)>()> > >':
boost_1_42_0/boost/proto/matches.hpp:994:13: instantiated from 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::and_boost::proto::wildcardns_::_ >, boost::proto::control::if_),
EmtnTermOrGram(boost::proto::_child_c<0>)>()> > >'
boost_1_42_0/boost/proto/matches.hpp:960:13: instantiated from 'boost::proto::detail::or_2&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::when()>, boost::proto::when()> >'
boost_1_42_0/boost/proto/matches.hpp:968:13: instantiated from 'boost::proto::detail::or_3&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::whenboost::proto::wildcardns_::_, boost::proto::control::if_boost::proto::_value()> >, mpl_::int_<1>()>, boost::proto::when()>,
boost::proto::when()> >'
boost_1_42_0/boost/proto/matches.hpp:968:13: instantiated from 'boost::proto::detail::or_4&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::when, boost::mpl::plus), EmtnTermOrGram(boost::proto::_child_c<1>)>()>,
boost::proto::whenboost::proto::wildcardns_::_, boost::proto::control::if_boost::proto::_value()> >, mpl_::int_<1>()>, boost::proto::when()>, boost::proto::when()> >'
boost_1_42_0/boost/proto/matches.hpp:985:13: instantiated from 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::or_, boost::mpl::plus), EmtnTermOrGram(boost::proto::_child_c<1>)>()>,
boost::proto::whenboost::proto::wildcardns_::_, boost::proto::control::if_boost::proto::_value()> >, mpl_::int_<1>()>, boost::proto::when()>, boost::proto::when()> > >'
boost_1_42_0/boost/proto/matches.hpp:985:13: instantiated from 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::or_ >'
boost_1_42_0/boost/proto/matches.hpp:505:13: instantiated from 'boost::proto::result_of::matches&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, EmotionGram>'
boost_1_42_0/boost/proto/operators.hpp:77:9: instantiated from 'boost::proto::detail::generate_if_left&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, boost::proto::exprns_::expr, 0l> >'
boost_1_42_0/boost/proto/operators.hpp:115:9: instantiated from 'boost::proto::detail::as_expr_if2&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, Plus2, void, void>'
boost_1_42_0/boost/proto/operators.hpp:154:9: instantiated from 'boost::proto::detail::as_expr_if&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, Plus2, void, void>'
main.cpp:33:86: instantiated from here
boost_1_42_0/boost/proto/matches.hpp:935:13: error: 'value' is not a member of 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::if_), EmtnTermOrGram(boost::proto::_child_c<0>)>()> >'
boost_1_42_0/boost/proto/matches.hpp: In instantiation of 'boost::proto::detail::or_2&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::when()>, boost::proto::when()> >':
boost_1_42_0/boost/proto/matches.hpp:968:13: instantiated from 'boost::proto::detail::or_3&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::whenboost::proto::wildcardns_::_, boost::proto::control::if_boost::proto::_value()> >, mpl_::int_<1>()>, boost::proto::when()>,
boost::proto::when()> >'
boost_1_42_0/boost/proto/matches.hpp:968:13: instantiated from 'boost::proto::detail::or_4&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::when, boost::mpl::plus), EmtnTermOrGram(boost::proto::_child_c<1>)>()>,
boost::proto::whenboost::proto::wildcardns_::_, boost::proto::control::if_boost::proto::_value()> >, mpl_::int_<1>()>, boost::proto::when()>, boost::proto::when()> >'
boost_1_42_0/boost/proto/matches.hpp:985:13: instantiated from 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::or_, boost::mpl::plus), EmtnTermOrGram(boost::proto::_child_c<1>)>()>,
boost::proto::whenboost::proto::wildcardns_::_, boost::proto::control::if_boost::proto::_value()> >, mpl_::int_<1>()>, boost::proto::when()>, boost::proto::when()> > >'
boost_1_42_0/boost/proto/matches.hpp:985:13: instantiated from 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::or_ >'
boost_1_42_0/boost/proto/matches.hpp:505:13: instantiated from 'boost::proto::result_of::matches&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, EmotionGram>'
boost_1_42_0/boost/proto/operators.hpp:77:9: instantiated from 'boost::proto::detail::generate_if_left&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, boost::proto::exprns_::expr, 0l> >'
boost_1_42_0/boost/proto/operators.hpp:115:9: instantiated from 'boost::proto::detail::as_expr_if2&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, Plus2, void, void>'
boost_1_42_0/boost/proto/operators.hpp:154:9: instantiated from 'boost::proto::detail::as_expr_if&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, Plus2, void, void>'
main.cpp:33:86: instantiated from here
boost_1_42_0/boost/proto/matches.hpp:960:13: error: 'value' is not a member of 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::and_boost::proto::wildcardns_::_ >, boost::proto::control::if_),
EmtnTermOrGram(boost::proto::_child_c<0>)>()> > >'
boost_1_42_0/boost/proto/matches.hpp: In instantiation of 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::or_ >':
boost_1_42_0/boost/proto/matches.hpp:505:13: instantiated from 'boost::proto::result_of::matches&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, EmotionGram>'
boost_1_42_0/boost/proto/operators.hpp:77:9: instantiated from 'boost::proto::detail::generate_if_left&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, boost::proto::exprns_::expr, 0l> >'
boost_1_42_0/boost/proto/operators.hpp:115:9: instantiated from 'boost::proto::detail::as_expr_if2&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, Plus2, void, void>'
boost_1_42_0/boost/proto/operators.hpp:154:9: instantiated from 'boost::proto::detail::as_expr_if&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, Plus2, void, void>'
main.cpp:33:86: instantiated from here
boost_1_42_0/boost/proto/matches.hpp:985:13: error: 'value' is not a member of 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::or_, boost::mpl::plus), EmtnTermOrGram(boost::proto::_child_c<1>)>()>,
boost::proto::whenboost::proto::wildcardns_::_, boost::proto::control::if_boost::proto::_value()> >, mpl_::int_<1>()>, boost::proto::when()>, boost::proto::when()> > >'
In file included from boost_1_42_0/boost/proto/core.hpp:26:0,
from boost_1_42_0/boost/proto/proto.hpp:12,
from EmtnGram.hpp:4,
from main.cpp:5:
boost_1_42_0/boost/proto/operators.hpp: In instantiation of 'boost::proto::detail::generate_if_left&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, boost::proto::exprns_::expr, 0l> >':
boost_1_42_0/boost/proto/operators.hpp:115:9: instantiated from 'boost::proto::detail::as_expr_if2&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, Plus2, void, void>'
boost_1_42_0/boost/proto/operators.hpp:154:9: instantiated from 'boost::proto::detail::as_expr_if&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >, Plus2, void, void>'
main.cpp:33:86: instantiated from here
boost_1_42_0/boost/proto/operators.hpp:77:9: error: 'value' is not a member of 'boost::proto::result_of::matches&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, EmotionGram>'
In file included from boost_1_42_0/boost/proto/core.hpp:22:0,
from boost_1_42_0/boost/proto/proto.hpp:12,
from EmtnGram.hpp:4,
from main.cpp:5:
boost_1_42_0/boost/proto/matches.hpp: In instantiation of 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::if_), EmtnTermOrGram(boost::proto::_child_c<0>)>()> >':
boost_1_42_0/boost/proto/matches.hpp:935:13: instantiated from 'boost::proto::detail::and_2&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::if_), EmtnTermOrGram(boost::proto::_child_c<0>)>()> > >'
boost_1_42_0/boost/proto/matches.hpp:994:13: instantiated from 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::and_boost::proto::wildcardns_::_ >, boost::proto::control::if_),
EmtnTermOrGram(boost::proto::_child_c<0>)>()> > >'
boost_1_42_0/boost/proto/matches.hpp:960:13: instantiated from 'boost::proto::detail::or_2&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::when()>, boost::proto::when()> >'
boost_1_42_0/boost/proto/matches.hpp:968:13: instantiated from 'boost::proto::detail::or_3&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::whenboost::proto::wildcardns_::_, boost::proto::control::if_boost::proto::_value()> >, mpl_::int_<1>()>, boost::proto::when()>,
boost::proto::when()> >'
boost_1_42_0/boost/proto/matches.hpp:968:13: instantiated from 'boost::proto::detail::or_4&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::when, boost::mpl::plus), EmtnTermOrGram(boost::proto::_child_c<1>)>()>,
boost::proto::whenboost::proto::wildcardns_::_, boost::proto::control::if_boost::proto::_value()> >, mpl_::int_<1>()>, boost::proto::when()>, boost::proto::when()> >'
boost_1_42_0/boost/proto/matches.hpp:985:13: instantiated from 'boost::proto::detail::matches_&>, 0l> >, EmotionExpr&>, 0l> > >, 2l> >&, boost::proto::exprns_::expr, 0l> >, 2l>, boost::proto::control::or_, boost::mpl::plus), EmtnTermOrGram(boost::proto::_child_c<1>)>()>,
boost::proto::whenboost::proto::wildcardns_::_, boost::proto::control::if_boost::proto::_value()> >, mpl_::int_<1>()>, boost::proto::when()>, boost::proto::when