標準のalgorithm
ヘッダーのいくつかのアルゴリズムはstd::
を必要としないという事実を知りました。find_if、for_each、countなどにstd ::が不要な理由はありますか?
例:
#include <vector>
#include <algorithm>
int main() {
std::vector<int> m;
count(m.begin(), m.end(), 0);
count_if(m.begin(), m.end(), [](auto){return true;});
for_each(m.begin(), m.end(), [](auto){});
find_if(m.begin(), m.end(), [](auto){return true;});
}
は、そのための具体的な理由はありますか? g++
とclang++
はどちらも上記のコードを受け入れます。
ADLのため、リファクタリングしてカスタムコンテナを使用する場合には、それに頼らないことをお勧めします。 –
https://en.wikipedia.org/wiki/Argument-dependent_name_lookup –