Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enum and string conversion #8

Closed
drofp opened this issue Feb 23, 2019 · 1 comment
Closed

Enum and string conversion #8

drofp opened this issue Feb 23, 2019 · 1 comment
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@drofp
Copy link
Owner

drofp commented Feb 23, 2019

Add support for converting from enum classto string easily. Should function as an equivalent of toString() in Java.

Some notes metioned in move.h are shown below.

// TODO: Add support for converting between enum class and strings
// https://github.com/aantron/better-enums
// https://sheep.horse/2018/5/converting_enum_classes_to_strings_and_back_in_c%2B%2B.html
// https://stackoverflow.com/questions/28828957/enum-to-string-in-modern-c11-c14-c17-and-future-c20
// ostream & operator << (ostream &out, const Move &value)
// {
//   switch (value)
//   {
//   case Move::kRock:
//     out << "Rock";
//     break;
//   case Move::kPaper:
//     out << "Paper";
//     break;
//   case Move::kScissors:
//     out << "Scissors";
//     break;

//   default:
//     break;
//   }

//   return out;
// }

Ideally, this will be templated for any enum -- check #12

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant