Algorithm: Add a TODO for the future

Currently e.g. this won't compile:
Utils::equal(&Class::toString, QLatin1String("xxx"));

because eqaul_to<QLatin1String> doesn't know how to compare
QString and QLatin1String.

In C++14, equal_to<> (without any template parameter) was added,
which simply works in that case.

Change-Id: I463d01e23f9f0379fea95ef1de4305751af8f1a7
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
This commit is contained in:
Daniel Teske
2015-09-04 15:02:33 +02:00
parent 33d1a91c4f
commit e818a4ed90

View File

@@ -147,6 +147,8 @@ template<typename R, typename S, typename T>
auto equal(R (S::*function)() const, T value)
-> decltype(std::bind<bool>(std::equal_to<T>(), value, std::bind(function, std::placeholders::_1)))
{
// This should use std::equal_to<> instead of std::eqaul_to<T>,
// but that's not supported everywhere yet, since it is C++14
return std::bind<bool>(std::equal_to<T>(), value, std::bind(function, std::placeholders::_1));
}