The following code is not an error in clang but isn't valid to my knowledge.
template <typename Pointer, typename F>
constexpr auto or_else(Pointer &&p, F &&f) -> remove_cvref_t<Pointer> {
if (not p) {
return FWD(f)( );
}
return std::move( p ); // not needed in clang 13+
}
std::unique_ptr<int> foo(std::unique_ptr<int> p) {
return or_else(std::move(p), [] { return std::make_unique<int>(42); });
}
https://gcc.godbolt.org/z/TzWf6Eqov
The move on p isn't required as of clang-13 while compiled with -std=c++17 -pedantic -pedantic-errors. The macro __cpp_implicit_move isn't defined either.