missing template - to_future

Issue #78 resolved
Nenad Vukicevic created an issue

'to_future' seems to be missing. This code does not compile:

future<int> f[2];
future<int,int,double> result = to_future (f[0], f[1], 1.0);

Comments (6)

  1. Dan Bonachea

    Bug confirmed.

    Full example:

    #include <upcxx/upcxx.hpp>
    using namespace upcxx;
    
    int main() {
    future<int> f[2];
    future<int,int,double> result = to_future (f[0], f[1], 1.0);
    return 0;
    }
    

    Too late to fix for this release.

  2. Amir Kamil

    This is what I believe is a spec-compliant implementation of to_future() using make_future() and when_all():

    template<typename T>
    struct future_collapse {
      using type = future<T>;
      static type make(T arg) {
        return make_future(std::move(arg));
      }
    };
    
    template<typename ...T>
    struct future_collapse<future<T...>> {
      using type = future<T...>;
      static type make(future<T...> arg) {
        return std::move(arg);
      }
    };
    
    template<typename ...Arg>
    auto to_future(Arg ...args)
      -> decltype(when_all(future_collapse<Arg>::make(args)...)) {
      return when_all(future_collapse<Arg>::make(args)...);
    }
    

    It may need to be modified to account for John's future1 stuff.

  3. Log in to comment