STEllAR-GROUP / hpx

The C++ Standard Library for Parallelism and Concurrency
https://hpx.stellar-group.org
Boost Software License 1.0
2.53k stars 431 forks source link

Start using C++17 features unconditionally #5497

Open msimberg opened 3 years ago

msimberg commented 3 years ago

Now that we require C++17 we can start using C++17 features more liberally without having to worry about fallbacks for older standards. Below is a grab bag of things we could start changing (please feel free to add to the list, or even better simply make the change if there's something missing). Keep in mind that we don't need to change every instance possible in one go, so don't be afraid to just make a local change while you're working on some piece of code (as we do right now with e.g. typedef to using). Small steps are better than no steps.

hkaiser commented 3 years ago

What about the hpx::apply <--> std::apply semantic mismatch? Should we start deprecating hpx::apply for some other name (hpx::fire_n_forget/hpx::post?) so we can substitute our hpx::util::invoke_fused with std::apply without causing undue confusion?

K-ballo commented 3 years ago
  • Replace various utilities with std counterparts (e.g. hpx::invoke -> std::invoke)

std::invoke implementations are considerably heavier at build time. It makes sense to replace hpx::invoke in examples and other user facing bits. In implementation code HPX_INVOKE should be used instead, to additionally reduce the stack noise in debug builds.

msimberg commented 3 years ago

What about the hpx::apply <--> std::apply semantic mismatch? Should we start deprecating hpx::apply for some other name (hpx::fire_n_forget/hpx::post?) so we can substitute our hpx::util::invoke_fused with std::apply without causing undue confusion?

Yes, I think we'll have to start deprecating it. I'm not sure what would be the best name for it. Another alternative would be to redirect users to hpx::execution::experimental::execute as an alternative, but it may be too early. That would require a customization for executors (just forward to post) and execute would have to become variadic.

std::invoke implementations are considerably heavier at build time. It makes sense to replace hpx::invoke in examples and other user facing bits. In implementation code HPX_INVOKE should be used instead, to additionally reduce the stack noise in debug builds.

Thanks, that makes sense. I suppose if that's the case we could at least putting invoke and friends in detail.