|
Boost : |
From: Neal D. Becker (ndbecker2_at_[hidden])
Date: 2004-03-19 08:35:54
Why not a default validator?
namespace po = boost::program_options;
namespace boost { namespace program_options {
template<typename T>
void validator<T>::operator()(any& v, const vector<string>& xs)
{
validators::check_first_occurence(v);
string s(validators::get_single_string(xs));
try {
v = any(lexical_cast<T>(s));
}
catch(const bad_lexical_cast&) {
throw validation_error("'" + s + "' doesn't look like a double
value.");
}
}
}}
This solves my immediate problem, which is that (strangely) program_options
has a validator for float but not for double.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk