Lambda return type deduction off of the generated lambda fctor (is it possible?)
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), Idstd::string()) << "]" << std::endl; // below is what I want to make work std::cout << "CallFctorDeduceRet returns [" << CallFctorDeduceRet( bindstd::string(&ReturnAString)) << "]" << std::endl; }
participants (1)
-
Brian Braatz