MSVC 2013でstd :: rbeginとstd :: rendを使用しています。GCC 4.9.1を使用してコードをコンパイルしようとしたとき、 3.5.0では、両方とも 'rbegin'と 'rend'が名前空間 'std'の一部ではないことを教えてくれます。std :: rbeginとstd :: rendはGCC 4.9とclang 3.5で機能します
は、次のコード例を参照してください。私は何か間違っているのですか、GCCとclangでまだ実装されていませんか?
// test.cpp
#include <vector>
#include <iostream>
#include <iterator>
int main(int, char**)
{
std::vector<int> test = {1, 2, 3 ,4, 5};
for (auto it = std::rbegin(test); it != std::rend(test); ++it) {
std::cout << *it << ", ";
}
std::cout << std::endl;
return 0;
}
GCC出力:
g++ --std=c++14 test.cpp -o test && ./test
test.cpp: In function ‘int main(int, char**)’:
test.cpp:10:20: error: ‘rbegin’ is not a member of ‘std’
for (auto it = std::rbegin(test); it != std::rend(test); ++it) {
^
test.cpp:10:45: error: ‘rend’ is not a member of ‘std’
for (auto it = std::rbegin(test); it != std::rend(test); ++it) {
^
打ち鳴らす出力を生成し、似ています:
clang++ --std=c++14 test.cpp -o test && ./test
あなたはクランでGCCを比較しているが、両方は、デフォルトでのlibstdC++を使用し、それは本当にあなたが比較されなければならない標準ライブラリの実装です。 –