内联 std::inner_product
据称内联 std::inner_product() 不会被 gcc 编译器内联 <海湾合作委员会4.1 编译器,根据以下 bug 。
因此我想实现我自己的inner_product版本。是 有现有的实施方案吗?
谢谢
Allegedly inlining std::inner_product() does NOT get inlined with gcc compiler < gcc 4.1
compilers, per the following bug .
Hence I would like to implement my own version of inner_product. Are
there existing implementation available?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您只需查看 C++ 头文件,找到定义,然后使用“inline”关键字(可能在您的命名空间中)重新定义它。例如,查看我的标题:
You just need to look in your C++ header files, find the definition, and redefine it with the "inline" keyword (possibly in your namespace). For example, looking at my headers:
明显的实现看起来像这样:
使用如此短的标识符可能是有问题的,但是对于像这样存在于标头中的代码,因此它被编译了无数次,短标识符可以节省解析时间......
The obvious implementations would look something like this:
Using such short identifiers is probably questionable, but for code like this that lives in a header so its compiled a gazillion times, short identifiers save parsing time...