【问题标题】:Compilation error with hpx::dataflow and member functionhpx::dataflow 和成员函数的编译错误
【发布时间】:2019-01-27 16:56:27
【问题描述】:

使用成员函数调用hpx::dataflow 的正确方法是什么?

hpx::async 工作正常,但我们不知道为什么hpx::dataflow 无法编译。

#include <hpx/hpx_main.hpp>
#include <hpx/hpx.hpp>
#include <memory>

class A {
public:
  A& do_work(double x, const A& y, const A& z) {
    i = x + y.i + z.i;
    return *this;
  }

  double i = 1.0;
};

int main() {
  // Create instances
  std::vector<std::unique_ptr<A>> vec;
  for (int i = 0; i < 3; ++i) {
    vec.emplace_back( std::make_unique<A>() );
  }

  std::vector<hpx::shared_future<A&>> a1(3);
  std::vector<hpx::shared_future<A&>> a2(3);

  // works
  a1[1] = hpx::async( &A::do_work, vec[1].get(), 1.0, *vec[0], *vec[2] );

  // compiler error here
  a2[1] = hpx::dataflow( hpx::util::unwrapping_all( &A::do_work ),
            vec[1].get(), 2.0, a1[0], a2[0] );

  return 0;
}

编译器错误提示:

hpx.cpp:29:100:   required from here
.../hpx/hpx/traits/get_remote_result.hpp:25:20: error: invalid cast from type ‘std::remove_reference<A&>::type’ {aka
‘A’} to type ‘A*’ return Result(std::move(rhs));

使用的 HPX 版本是 1.2.0 和 GCC 8.1。

【问题讨论】:

  • 编译器还会准确说明发生在哪一行,所以不要忽略关键信息!

标签: c++ hpx


【解决方案1】:

这对我来说似乎是一个错误。我为此在存储库中创建了一个问题:https://github.com/STEllAR-GROUP/hpx/issues/3639

【讨论】:

猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-08-31
相关资源
最近更新 更多