Answer by Eric for handling void type in template
Not certain this is valid, but:template<>void Foo<T>( T(*Func)() ) { // do something first (e.g. some setup) return tearDown(Func());}template<>T tearDown<T>( T result) { // do...
View ArticleAnswer by K-ballo for handling void type in template
Given that your operation does not depend on the result of the function, you can do it without a specialization. It is ok for a function returning void to return an expression of type void. So the...
View ArticleAnswer by Pubby for handling void type in template
If all you're doing is taking and releasing a lock then you should use RAII instead of calling lock/unlock functions. This is especially true if Func could throw, as if it does the code after it will...
View ArticleAnswer by gustaf r for handling void type in template
No, you need the specialization since you cannot store void (as in T result = Func();).If you're never gonna use the value, and you are fine with calling Func as the last thing, then you can...
View Articlehandling void type in template
I have a templated function that invokes another function and stores its return value, then does some work before returning the value. I'd like to extend this to handle T = void, and was wondering if...
View Article