On Jun 12, 2015, at 09:30, Peter Dimov
wrote: But the compiler is able to instantiate those eagerly if a type argument is specified (char) that does not depend on the outer template parameter.
It is. What I meant was: <snip>
template
inline std::basic_ostream & operator <<(std::basic_ostream & os, const Enum& value) { return os << value.template _to_basic_string<Ch>(); } You'll have to define _to_basic_string for char, wchar_t, char16_t and char32_t if you want to cover all cases, of course.
If you want to restrict yourself to char-based streams:
template
inline std::basic_ostream & operator <<(std::basic_ostream & os, const Enum& value) { return os << value._to_string(); }
Ah, cool, yes. As long as I only actually support char streams, this looks
almost like an eta-expansion. I was able to use it on std::string as well
(std::basic_string<Char>), and replaced the reference to ios_base::failbit with
std::basic_istream