drofp/MyRPS

Enum and string conversion

Closed this issue · 1 comments

drofp commented

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