Skip to content

Instantly share code, notes, and snippets.

@EricWF
Created April 28, 2014 02:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EricWF/11360140 to your computer and use it in GitHub Desktop.
Save EricWF/11360140 to your computer and use it in GitHub Desktop.
enum class A
{
none, one
};
struct A_parser
{
static A parse(std::string const & option)
{
if (option == "none") {
return A::none;
}
else if (option == "one") {
return A::one;
} else {
throw 0;
}
}
};
template <class ValueType, class Parser>
class value_option
{
void parse_option(std::string const & opt)
{
m_value = Parser::parse(opt);
}
ValueType value() { return m_value; }
private:
ValueType m_value;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment