I have some trouble forward declaring a function that uses boost::enable_if
: the following piece of code gives me a compiler error:
// Declaration
template <typename T>
void foo(T t);
// Definition
template <typename T>
typename boost::enable_if<boost::is_same<T, int> >::type foo(T t)
{
}
int main()
{
foo(12);
return 0;
}
When compiling, I get an "ambiguous call to foo" error. According to the definition of enable_if
, the 'type' typedef corresponds to void
when the condition is true, so as far as I can see, the two signatures of foo
match. Why does the compiler think they are different, and is there a correct way to forward declare foo
(preferably without repeating the enable_if
part)?