O
template <typename T, typename F>
bool foo (const T & x, const F & a, const F & b)
{
return a (x) == b (x);
}
template <typename T>
bool bar (const T & x, const T & a, const T & b)
{
return foo (
x,
[&] (const T & arg) {return a == arg;},
[&] (const T & arg) {return b == arg;});
}
int main ()
{
bar (0, 0, 0);
}
Почему дедукция ломается? Выдаёт вот такую ошибку
no matching function for call to ‘foo(const int&, bar(const T&, const T&, const T&) [with T = int]::<lambda(const int&)>, bar(const T&, const T&, const T&) [with T = int]::<lambda(const int&)>)’
deduced conflicting types for parameter ‘const F’ (‘bar(const T&, const T&, const T&) [with T = int]::<lambda(const int&)>’ and ‘bar(const T&, const T&, const T&) [with T = int]::<lambda(const int&)>’)
Помогает добавить третий параметр в
foo
, например вот так template <typename T, typename F1, typename F2>
Но должно ведь работать и с одним, разве нет???