Сообщение Перегрузка методов с лямбдами от 07.01.2017 11:43
Изменено 07.01.2017 11:44 Barbar1an
Перегрузка методов с лямбдами
template<class T> class CList : public std::list<T>
{
public:
template<class Pred> bool Contain(Pred p)
{
return std::find_if(begin(), end(), p) != end();
}
bool Contain(const T & v)
{
return std::find(begin(), end(), v) != end();
}
}
CList<int> a;
a.Contain([](auto i){ return i == 5; }); //ok
a.Contain(5); //term does not evaluate to a function taking 1 arguments (compiling source file History.cpp)
// bool CList<int>::Contain<int>(Pred)' being compiled ??????
как ?
Перегрузка методов с лямбдами
template<class T> class CList : public std::list<T>
{
public:
template<class Pred> bool Contain(Pred p)
{
return std::find_if(begin(), end(), p) != end();
}
bool Contain(const T & v)
{
return std::find(begin(), end(), v) != end();
}
}
CList<int> a;
a.Contain([](auto i){ return i == 5; }); //ok
a.Contain(5); //term does not evaluate to a function taking 1 arguments
// bool CList<int>::Contain<int>(Pred)' being compiled ??????
как ?