[英]Does gcc 6 support the use of std::sample (c++17)?
我正在嘗試使用gcc版本6.3.0使用以下命令編譯包含std::sample
這段c ++ 17代碼: g++ -std=gnu++17 -c main.cpp
。
但是我得到了這個: error: 'sample' is not a member of 'std'
......
#include <vector>
#include <algorithm>
#include <random>
int main()
{
std::vector<int> a{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
std::vector<int> b(5);
std::sample(a.begin(), a.end(),
b.begin(), b.size(),
std::mt19937{std::random_device{}()});
return 0;
}
gcc 6是否支持使用std::sample
? (用gcc 8.2.0編譯好)
我在這兩頁上找不到答案:
gcc 6是否支持使用std :: sample?
不。您需要GCC 7.從GCC 7發行說明 :
對C ++ 17的實驗支持,包括以下新功能:
...
std :: sample,std :: default_searcher,std :: boyer_moore_searcher和std :: boyer_moore_horspool_searcher;
對於GCC 7,您可能需要-std=c++1z
或-std=gnu++1z
因為它是實驗性的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.