Ticket #12889: lexical_cast.cxx
| File lexical_cast.cxx, 414 bytes (added by , 6 years ago) |
|---|
| Line | |
|---|---|
| 1 | #include <iostream> |
| 2 | |
| 3 | #include <boost/lexical_cast.hpp> |
| 4 | |
| 5 | enum class Foo |
| 6 | { |
| 7 | bar, |
| 8 | baz |
| 9 | }; |
| 10 | |
| 11 | std::ostream &operator <<(std::ostream &out, Foo f) |
| 12 | { |
| 13 | switch (f) |
| 14 | { |
| 15 | case Foo::bar: out << "bar"; break; |
| 16 | case Foo::baz: out << "baz"; break; |
| 17 | default: out << "(invalid)"; break; |
| 18 | } |
| 19 | return out; |
| 20 | } |
| 21 | |
| 22 | int main() |
| 23 | { |
| 24 | auto s = boost::lexical_cast<std::string>(Foo::baz); |
| 25 | std::cout << s << '\n'; |
| 26 | } |
