Regarding binary predicate Compare

女生的网名这么多〃 提交于 2019-12-24 03:54:05

问题


My reference is to the binary predicate Compare comp expected in the overload of std::lower_bound etc.:

The description reads:

The signature of the predicate function should be equivalent to the following:

bool pred(const Type1 &a, const Type2 &b);

While the signature does not need to have const &, the function must not modify the objects passed to it and must be able to accept all values of type (possibly const) Type1 and Type2 regardless of value category (thus, Type1 & is not allowed, nor is Type1 unless for Type1 a move is equivalent to a copy (since C++11)).

I am a bit confused by the following part of the description (which appears to be contradictory?):

...the function must not modify the objects passed to it and must be able to accept all values of type (possibly const) Type1 and Type2 regardless of value category (thus, Type1 & is not allowed, nor is Type1 unless for Type1 a move is equivalent to a copy (since C++11))

If the function should accept all value categories, why is Type1 not allowed? Also, why should a move be equivalent to copy for Type1 to be allowed, since C++11?

来源:https://stackoverflow.com/questions/58194906/regarding-binary-predicate-compare

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!