
Hi, Reading http://www.boost.org/doc/libs/1_36_0/doc/html/function/reference.html it says: A function object f is compatible if for the given set of argument types Arg1, Arg2, ..., ArgN and a return type ResultType, the appropriate following function is well-formed: // if ResultType is not void ResultType foo(Arg1 arg1, Arg2 arg2, ..., ArgN argN) { return f(arg1, arg2, ..., argN); } // if ResultType is void ResultType foo(Arg1 arg1, Arg2 arg2, ..., ArgN argN) { f(arg1, arg2, ..., argN); } I believe the "If ResultType is void" is not needed. We can return void in C++. -Thorsten

AMDG Thorsten Ottosen wrote:
// if ResultType is void ResultType foo(Arg1 arg1, Arg2 arg2, ..., ArgN argN) { f(arg1, arg2, ..., argN); }
I believe the "If ResultType is void" is not needed. We can return void in C++.
http://www.boost.org/doc/html/function/faq.html#id2914425 In Christ, Steven Watanabe

Steven Watanabe skrev:
AMDG
Thorsten Ottosen wrote:
// if ResultType is void ResultType foo(Arg1 arg1, Arg2 arg2, ..., ArgN argN) { f(arg1, arg2, ..., argN); }
I believe the "If ResultType is void" is not needed. We can return void in C++.
Hm. Right, but I did get that from reading the docs. That could be said more directly IMO. And the fix to the code would be to say return static_cast<ResultType>(f(arg1,....)) would that not "swallow the return value" too? -Thorsten

AMDG Thorsten Ottosen wrote:
Hm. Right, but I did get that from reading the docs. That could be said more directly IMO. And the fix to the code would be to say
return static_cast<ResultType>(f(arg1,....))
would that not "swallow the return value" too?
It would also allow explicit conversions: int f() { return 1; } boost::function<std::vector<double>() > func(&f); In Christ, Steven Watanabe

Steven Watanabe skrev:
AMDG
Thorsten Ottosen wrote:
Hm. Right, but I did get that from reading the docs. That could be said more directly IMO. And the fix to the code would be to say
return static_cast<ResultType>(f(arg1,....))
would that not "swallow the return value" too?
It would also allow explicit conversions:
int f() { return 1; }
boost::function<std::vector<double>() > func(&f);
I can't compile std::vector<double> v = static_cast<std::vector<double>>(42); what am I overlooking? -Thorsten

AMDG Thorsten Ottosen wrote:
I can't compile
std::vector<double> v = static_cast<std::vector<double>>(42);
what am I overlooking?
I don't know. The following compiles for me with msvc 9.0 and gcc 4.3.0 #include <vector> int main() { std::vector<double> v = static_cast<std::vector<double> >(42); } In Christ, Steven Watanabe
participants (2)
-
Steven Watanabe
-
Thorsten Ottosen