{"action":"closed","issue":{"url":"https://api.github.com/repos/boostorg/lexical_cast/issues/14","labels_url":"https://api.github.com/repos/boostorg/lexical_cast/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/boostorg/lexical_cast/issues/14/comments","events_url":"https://api.github.com/repos/boostorg/lexical_cast/issues/14/events","html_url":"https://github.com/boostorg/lexical_cast/issues/14","id":69485275,"number":14,"title":"Should bool shl_input_streamable(InputStreamable& input) take a const reference?","user":{"login":"snarkmaster","id":2081923,"avatar_url":"https://avatars.githubusercontent.com/u/2081923?v=3","gravatar_id":"","url":"https://api.github.com/users/snarkmaster","html_url":"https://github.com/snarkmaster","followers_url":"https://api.github.com/users/snarkmaster/followers","following_url":"https://api.github.com/users/snarkmaster/following{/other_user}","gists_url":"https://api.github.com/users/snarkmaster/gists{/gist_id}","starred_url":"https://api.github.com/users/snarkmaster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/snarkmaster/subscriptions","organizations_url":"https://api.github.com/users/snarkmaster/orgs","repos_url":"https://api.github.com/users/snarkmaster/repos","events_url":"https://api.github.com/users/snarkmaster/events{/privacy}","received_events_url":"https://api.github.com/users/snarkmaster/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-04-20T01:22:27Z","updated_at":"2015-04-20T01:41:59Z","closed_at":"2015-04-20T01:41:59Z","body":"I'm referring to this line:\r\nhttps://github.com/boostorg/lexical_cast/blob/c4fcfc33afcc4069c0fbc3b88e0578989311466b/include/boost/lexical_cast/detail/converter_lexical_streams.hpp#L224\r\n\r\nI have an enum class, for which I defined a simple ostream operator:\r\n\r\n```\r\nstd::ostream& operator<<(std::ostream& os, const FileExists& e) {\r\n  os << enumName(e);    \r\n  return os;\r\n}\r\n```\r\n\r\nUsing an ostream directly works fine, e.g.\r\n\r\n```\r\nstd::ostrstream s;\r\ns << FileExists::FAIL;\r\n```\r\n\r\nHowever, boost::lexical_cast fails:\r\n\r\n```\r\nboost::lexical_cast<std::string>(FileExists::FAIL);\r\n```\r\n\r\nThe error is useless: cannot bind ‘std::basic_ostream<char>’ lvalue to ‘std::basic_ostream<char>&&’\r\n\r\nHowever, it's easy enough to reproduce:\r\n\r\n```\r\ntemplate <typename T>\r\nbool willFail(T& e) {\r\n  std::ostrstream s;\r\n  return !(s << e).fail();\r\n}\r\n```\r\n\r\nThe error is now pretty obvious: invalid initialization of non-const reference of type ‘FileExists&’ from an rvalue of type ‘FileExists’.\r\n\r\nMaking `shl_input_streamable` take a const reference would fix this, but I'm not sure if it breaks anything else.\r\n"}}