Created
April 28, 2014 02:02
-
-
Save EricWF/11360140 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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