Is there a reference_wrapper for rvalue references?

My take on this.

20.8.10.1.2/10 in N3225

The values of the bound arguments v1, v2, …, vN and their corresponding types V1, V2, …, VN
depend on the types TiD derived from the call to bind and the cv-qualifiers cv of the call wrapper g as
follows:

  • if TiD is reference_wrapper, the argument is tid.get() and its type Vi is T&;
  • if the value of is_bind_expression::value is true, the argument is tid(std::forward(uj)…)
    and its type Vi is result_of::type;
  • if the value j of is_placeholder::value is not zero, the argument is std::forward(uj)
    and its type Vi is Uj&&;
  • otherwise, the value is tid and its type Vi is TiD cv &.

So the only possibility to have a rvalue reference is to have is_bind_expression<TiD>::value true or is_placeholder<TiD>::value not zero. The second possibility has implications you don’t want and achieving the wanted result with the first would imply that the problem we are trying to solve is solved if we restrict to the standard provided types. So, the only possibility would be to provide your own wrapper and a specialisation for is_bind_expression<TiD> (that is allowed by 20.8.10.1.1/1) as I don’t see one.

Leave a Comment