![](/img/trans.png)
[英]Can a noexcept function still call a function that throws in C++17?
[英]C++17 no matching function for call to reduce error
此代码来自 Apress 的C++17 标准库快速参考书:
#include <numeric>
#include <vector>
using namespace std;
int main() {
vector vec {4,2,5,1,3,6};
int sum = reduce( begin(vec), end(vec));
}
当我使用Windows 7上的选项-std=c++17
(或-std=gnu++2a
)使用g++-9.2
编译它时,我得到:
error: no matching function for call to 'reduce(std::vector<int, std::allocator<int> >::iterator, std::vector<int, std::allocator<int> >::iterator)'
这段代码有什么问题? 谢谢你。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.