使用g ++-5.1.0和Boost错误编译C ++ 17 gcd

问题描述 投票:-1回答:2

我正在尝试使用Windows 7上的C++17 gcdg++-5.1.0 (2015)编译此示例Boost-1.71.0代码。

#include <numeric>

int main() {
  int x=90;
  int y=9;
  return gcd(x,y);
}

[当我使用:编译时

g++ gcd.cpp -IC:\Programs\boost-1.71.0\include -std=c++17

它说error: 'gcd' was not declared in this scope

如果这次是#include <boost/ratio/detail/mpl/gcd.hpp>,它表示error: missing template arguments before '(' token是指gcd的(

如何使g++-5.1.0正确处理C++17代码?谢谢。

c++ boost g++ c++17
2个回答
0
投票

[::mpl::gcd(x,y)在C ++ 17中什么都没有。

我怀疑您的意思是std::gcd

[此外,实现std::gcd(C ++ 17功能)的gcc-5.1(于2015年4月发布)的几率很低。它可以在此处实现-但这不是肯定的事情。


0
投票

我无法让它与:: mpl一起运行,因为它似乎是比率的辅助结构。另一方面,您的意思是:

boost :: math :: gcd(x,y);

© www.soinside.com 2019 - 2024. All rights reserved.