c++ - hpx::dataflow 和成员函数的编译错误

标签 c++ hpx

使用成员函数调用 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。

最佳答案

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

关于c++ - hpx::dataflow 和成员函数的编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54390555/

相关文章:

c++ - for 循环期间的动态分配会造成内存泄漏吗?

c++ - 未命名的函数参数

c++ - 有没有办法在不包含 stdafx.h 的情况下使用 VC++ 2010?

c++ - 根据 pair.first 对 std::pair<int, std::unique_ptr<const T>> 的 vector 进行排序

c++ - TinyXML 无法读取自己的文件

c++ - HPX transform_reduce

hadoop - 问:HPX 与 'apache cloud computing'(例如与 spark)相比如何公平?

c++ - 在集合中查找结构 vector

c++ - ptree 迭代器成员未被自动完成识别?