boost::function "could not deduce template argument ..."
I apologize if this isn't the sort of question this list is intended
for, but if anyone could help me with my lack of sufficient template
howto skill I would appreciate it.
Essentially what I have is class template for boost::function1
Derrick Hathaway wrote:
I apologize if this isn't the sort of question this list is intended for, but if anyone could help me with my lack of sufficient template howto skill I would appreciate it.
<snip>
The problem is when I compile I get the error message "could not deduce template argument for 'ValueType'" when I compile. Any idea what I'm doing wrong? I have attached example code. I am using MS Visual Studio 8, and boost 1.34.1.
Thanks in advance.
-Derrick
Hi Derrick,
The problem is that you are trying to get the compiler to deduce what
instantiation of predicate is in use based on the nested type. That is,
your code is requesting that the compiler figure out ValueType based on
the boost::function1 type. From what I can understand, the standard
forbids this since in general this is not possible. There is a post
here that goes into more detail:
http://www.thescripts.com/forum/thread62685.html
I can come up with only a few options:
(1) Tell the compiler which version to use. It works but is very verbose:
predicate<foo>::type lt_and_gt(operator &<foo>(lt,gt));
However, if you are going to do that, it is easier to rename operator &
to And() so that you can write:
predicate<foo>::type lt_and_gt(And<foo>(lt,gt));
(2) Rewrite operator & to be deducible:
#include
participants (2)
-
David Walthall
-
Derrick Hathaway