Boost logo

Boost :

From: Neal D. Becker (nbecker_at_[hidden])
Date: 2003-05-23 06:46:03

Why not a generic default validator?
BTW, I know "typeid (T).name()" doesn't really work, but I'm not sure what
would be better.

If not totally generic, then instead at least all fundamental types could be
handled by a single generic function, using maybe is_pod to dispatch.

namespace boost { namespace program_options {
    template<typename T>
    void validator<T>::operator()(any& v, const vector<string>& xs)
        string s(get_single_string(xs));
        try {
            v = any(lexical_cast<T>(s));
        catch(bad_lexical_cast&) {
            throw validation_error("'" + s + "' doesn't look like a " + typeid
} }

Boost list run by bdawes at, gregod at, cpdaniel at, john at