On Sunday 03 August 2014 16:27:13 Andrey Davydov wrote:
On Sat, Aug 2, 2014 at 2:46 AM, Nathan Crookston
wrote:
I suppose that would break cases like:
std::string getStr(); print(std::string_ref sr) { std::cout << sr << std::endl; }
print(getStr());
Causing people to have to write print(getStr().c_str()).
It's possible to add `string_ref(reference_wrapper<const std::string>)` constructor to allow people write `print(boost::cref(getStr()))` instead of `print(getStr().c_str())`.
boost::reference_wrapper will not construct from rvalues as of 1.56. std::reference_wrapper already doesn't. 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.