1

次のコードは VC 2010 で非常にうまくコンパイルできますが、Mac で xcode 4.6.3 を使用してコンパイルすると、質問のタイトルが示すようにコンパイル エラーが発生します。何か案は?ありがとう。

         std::vector<int> x_array;
    std::vector<int> y_array;

    int min_x,min_y,max_x,max_y;
    auto temp = std::minmax_element(x_array.begin(),x_array.end());
    min_x = *(temp.first);
    max_x = *(temp.second);
4

2 に答える 2

2

-stdlib=libc++の代わりに使用-stdlib=libstdc++:

$ cat test.cpp
#include <iostream>
#include <algorithm>
#include <vector>

int main() {
    std::vector<int> x_array;
    std::vector<int> y_array;

    int min_x,min_y,max_x,max_y;
    auto temp = std::minmax_element(x_array.begin(),x_array.end());
    min_x = *(temp.first);
    max_x = *(temp.second);
    return 0;
}

$ clang++ -std=c++0x -stdlib=libc++ -o test test.cpp
$ clang++ -std=c++0x -stdlib=libstdc++ -o test test.cpp
test.cpp:10:22: error: no member named 'minmax_element' in namespace 'std'
    auto temp = std::minmax_element(x_array.begin(),x_array.end());
                ~~~~~^
1 error generated.
于 2013-10-21T10:11:43.263 に答える