Elementwise perfect forwarding of a member range
I'll start with some direct review of what you've implemented. After the bullets, however, I go into some concerns about whether this should be used. Thanks for the interesting idea; reviewing it made me re-examine several things I thought I already knew.


Like std::forward you should consider making forward_as a constexpr function.
You could avoid some of the pre-C++14 verbosity by using decltype inside forward_as (although the auto return type sounds better still):

    return static_cast&lt;decltype(forward_as&lt;T, U&gt;(u))&gt;(u);

How do you know whether for (auto&amp;&amp; r : t.range) will iterate over objects owned by t?
Admittedly a bikeshed point, I don't like the way the name forward_as&lt;T&gt;(u) reads; perhaps forward_if&lt;T&gt;(u) or even move_if_rvalue&lt;T&gt;(u) would help this not look like it returns an expression of a T-based type.


However like Kerrek SB's comment on the referenced question, I worry about the state of the main object when forwarding or moving its members. What are the rules for doing this safely? Your examples seem to show forwarding only a single member, but what are the rules when forwarding different parts of the same object? What are the code review guidelines to ensure that problems are not introduced in later edits?

To sum up, I mistrust this. It might just be my own lack of familiarity with such a use case. But it also reflects an uncertainty that optimizing for move is likely to be worth it in these cases. If this is actually a bottleneck or potential bottleneck in the code, are there better alternatives? Does bar even overload on r-value types? Should foo receive t.range instead of t, or will std::for_each be able to generate r-values automatically:

    std::for_each(std::begin(t.range), std::end(t.range), bar)


(If so, I haven't figured out the syntax to support it in your sample with bar as a function template. Using instead a struct with overloaded operator(), it appears to suggest we shouldn't assume the range contains r-values.)