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)
    {
        check_first_occurence(v);
        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 
(T).name());
        }
    }
} }

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

Reply via email to