Thanks @Arthur and @Zhihao.
About these two comments:
> You can (and should) std::move(arr[Idx]).
and
> Because of everything you said about MSVC, I suggest that your proposal
> (and vendors' implementations too) should actually say
>
> return std::move(arr[Idx]); // correct in practice
>
> not
>
> return std::move(arr)[Idx]; // pedantically correct but fails on MSVC
>
> The effect is the same, on everything-but-MSVC; and on MSVC the former
> is preferable. (AFAIK, both are equally correct as far as the paper
> standard is concerned.)
I can't understand whether there's a real difference in either of the
return statements if the return type of std::get is T&&. I'd expect an
implicit cast to T&& on MSCV (and no cast on other compilers).
Lvalue doesn't bind to T&&, and
MSVC did not implement array
rvalues correctly:
But other than the built-in array,
no operator[] in the standard is
aware of value-category (std::array,
std::vector, etc.) The built-in
array is special here as its "[i]"
models after a member access.
--Zhihao Yuan, ID lichray
The best way to predict the future is to invent it.
_______________________________________________