#include <algorithm>
#include <vector>
template <class BidirectionalIterator, class UnaryPredicate>
BidirectionalIterator partition(BidirectionalIterator first,
BidirectionalIterator last, UnaryPredicate pred)
{
while (first != last) {
while (pred(*first)) {
++first;
if (first == last) return first;
}
do {
--last;
if (first == last) return first;
} while (!pred(*last));
std::swap(*first, *last);
++first;
}
return first;
}
int main() {
std::vector<int> v = { 1, 55, 17, 65, 40, 18, 77, 37, 77, 37 };
partition(v.begin(), v.end(), [](const int &i) {
return i < 40;
});
return 0;
}
Kod derlenmiyor. Hem clang ++ (3.5.2/cygwin) hem de Visual Studio (2013) belirsiz çağrıdan şikayet ediyor. using
yönergesi kullanılmadığından, neyin yanlış olduğunu anlamıyorum. Başarıyla derlemek için ::
öneki yardımcı olur.clang ++: error: 'bölüm' çağrısı belirsiz