「純」謂詞我的意思是他們只有取決於他們的論點。因此,下面的函數對象是一個有效的謂語,用於說,std :: sortSTL謂詞是否必須是純謂詞?
// A predicate for sorting objects of type T2 that relies on an
// object of type T1.
class APredicate {
T1 &someObj;
APredicate(T1 &someObject) : someObj(someObject) {};
bool operator() (T2 thing1, T2 thing2) {
return someObj.someFn(thing1) < someobj.someFn(thing2);
}
}
這是否有效?總是有效的?還是它取決於someObj.SomeFn()實際上做了什麼?
可能重複[std :: set'有什麼問題?](http://stackoverflow.com/questions/5397616/what-is-wrong-with-stdset) – Nawaz 2011-05-25 05:49:50
是的。請參閱可能的重複答案:[std :: set'有什麼問題?](http://stackoverflow.com/questions/5397616/what-is-wrong-with-stdset) – Nawaz 2011-05-25 05:50:59
是的。你可以在我之前的評論中提供的鏈接中閱讀。 – Nawaz 2011-05-25 06:02:27