std :: transform_reduce是否具有可移植的执行策略?

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

我可以在Fedora和Ubuntu上使用gcc 9.2.1编译以下代码(使用std::transform_reduce),但是尝试在clang see godbolt上编译失败,并且我得到了一份报告,指出某些FSF版本的gcc 9.2 .1还拒绝编译代码,要求std::execution_policy作为std::transform_reduce的第一个参数。

#include <vector>
#include <algorithm>
#include <numeric>

auto brokenvector(std::vector<int> const& a, std::vector<int> const& b) 
{
  return std::transform_reduce(cbegin(a), cend(a), cbegin(b), 0, std::plus<>{},std::multiplies<>{});
}

我在这里特别不能使用std::execution_policy,并且cppreference和C ++草案标准文档n4659都显示重载没有执行策略。

我是否进入了某种政治雷区,其中一半的可用编译器拒绝实施该标准,或者代码不正确?

c++
1个回答
3
投票

这是libstdc ++与libc ++的问题。 libc ++实现了the function,您可以在此-stdlib=libc++中使用live example看到它与Godbolt上的clang一起使用。 gcc现在在trunk中实现了它,但是当前发布的版本没有实现。该功能已添加到this commit

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