I am currently learning about concepts in C++20, and came across this example:
template <typename From, typename To>
concept is_convertible_without_narrowing = requires (From&& from) {
{ std::type_identity_t<To[]>{std::forward<From>(from)}} -> std::same_as<To[1]>;
};
I am curious if the following can be considered a correct alternative implementation of the above:
template <typename From, typename To>
concept is_convertible_without_narrowing = requires (From&& from) {
{ To{std::forward<From>(from)} } -> std::same_as<To>;
}
or, even simpler:
template <typename From, typename To>
concept is_convertible_without_narrowing = requires (From&& from, To&& to) {
to = {from};
}