Date: Wed, 4 Jun 2025 11:25:50 +0100
On Wed, 4 Jun 2025, 10:19 Tymi, <tymi.cpp_at_[hidden]> wrote:
> template<typename T, typename U>
> constexpr std::remove_reference_t<T>&& move_as(U& u) noexcept
> {
> return static_cast<T&&>(static_cast<U&&>(u));
> }
>
> Would work as a possible implementation (example)
>
Why would you not want it to accept rvalues? Why would you want
move_as<T&>(x) to compile but return an rvalue not an lvalue? How would you
prevent dangling references?
Maybe you should try using this in your own code and experiment with it and
find the problems, as the proposal doesn't seem ready yet (leaving aside
whether it's even useful or not).
> template<typename T, typename U>
> constexpr std::remove_reference_t<T>&& move_as(U& u) noexcept
> {
> return static_cast<T&&>(static_cast<U&&>(u));
> }
>
> Would work as a possible implementation (example)
>
Why would you not want it to accept rvalues? Why would you want
move_as<T&>(x) to compile but return an rvalue not an lvalue? How would you
prevent dangling references?
Maybe you should try using this in your own code and experiment with it and
find the problems, as the proposal doesn't seem ready yet (leaving aside
whether it's even useful or not).
Received on 2025-06-04 10:26:09