Accept LPC function object callbacks that can only be invoked by rvalue

Issue #609 resolved
Dan Bonachea created an issue

It's currently underspecified whether various UPC++ callbacks into user code will accept a function object that can only be invoked by rvalue, eg:

#include <upcxx/upcxx.hpp>
#include <iostream>
#include "util.hpp"

struct MyFn {
 void operator()() && {  // <- note the && here
   say() << "Tada"; 
 }
};

int main() {
  upcxx::init();

  upcxx::current_persona().lpc(MyFn()).wait(); // obscure compile error

  upcxx::finalize();
  return 0;
}

Colin noticed this particular case (round-trip LPC) happens to currently generate a compile error, a behavior dating back to at least release 2021.3.0.

However such function objects ARE correctly handled by a number of other callback interfaces in UPC++.

I'm not sure we want to go so far as to mandate behavior for this unusual corner-case in the specification, but as a quality-of-implementation feature it would be nice to support such function objects in places where it doesn't entail significant additional effort.

Comments (3)

  1. Log in to comment