|
Boost Users : |
From: Brian Braatz (brianb_at_[hidden])
Date: 2004-12-21 15:05:54
I wrote up the simple example that shows what I am trying to figure out
Basically, I am trying to pull the deduced return type (or explicitly
passed as a template param in lambda bind()) in my template:
Any help or direction is greatly appreciated
template <typename CURRIEDTYPE>
// Id class for currying type without creating the object
class Id
{
public:
typedef CURRIEDTYPE TYPE;
};
// Explictly pass IN a return type
template < typename TFUNCTOR, typename TRET>
TRET CallFctorPassInRet ( TFUNCTOR & functor, Id<TRET> & )
{
Id<TRET>::TYPE TRet;
TRet = functor();
return TRet;
}
std::string ReturnAString()
{
return "this is a string";
}
// try to get return type from the lambda fctor
// Below does not compile- but it is along the lines of what I
// WANT to do- note that I am trying to get from the Lambda
functor the deduced return type
template < typename TFUNCTOR>
TFUNCTOR::result_type CallFctorDeduceRet( TFUNCTOR & functor)
{
return functor();
}
void Test_LambdaRetDeduction()
{
std::cout << "CallFctorPassInRet returns [" <<
CallFctorPassInRet( bind(&ReturnAString), Id<std::string>()) << "]" <<
std::endl;
// below is what I want to make work
std::cout << "CallFctorDeduceRet returns [" <<
CallFctorDeduceRet( bind<std::string>(&ReturnAString)) << "]" <<
std::endl;
}
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