Found workaround how to use rvalue as lvalue :
&(std::string()=std::string("Hello World"));
but not sure is it legal to use this construction.
Code same to this is working for me
typedef std::pair<const char *, const std::string *> custom_pair;
std::ostream & operator <<(std::ostream & os, const custom_pair & kv)
{
if (kv.first && kv.second && !kv.second->empty())
os << kv.first << *kv.second;
return os;
}
std::ostringstream q;
q << custom_pair("example_string=", &(std::string() = IntToString(1)));
where custom_pair
constructor needs address as second parameter, but can someone explain is it correct to use this?