On Sun, Aug 3, 2014 at 4:55 PM, Andrey Semashev <andrey.semashev@gmail.com> wrote:
boost::reference_wrapper will not construct from rvalues as of 1.56. std::reference_wrapper already doesn't.
OK, it's possible to write custom function template<class charT, class traits, class Allocator> basic_string_ref<charT, traits> unsafe_make_ref(std::basic_string<charT, traits, Allocator> && str) { return { str }; } and use it. Even then, IMHO string_ref should not
require these tricks, it should work transparently. I'm ok with leaving it vulnerable to incorrect use if it's not possible to protect it without sacrificing usability.
I'm not sure that one extra call [`print(unsafe_make_ref(getStr()))` instead of `print(getStr())`] is too high usability price for the safety in common case. Of course, it's only IMHO. -- Andrey