|
Boost-Commit : |
From: ghost_at_[hidden]
Date: 2007-08-05 14:38:13
Author: vladimir_prus
Date: 2007-08-05 14:38:07 EDT (Sun, 05 Aug 2007)
New Revision: 38459
URL: http://svn.boost.org/trac/boost/changeset/38459
Log:
When parsing vector<T>, use validator for
type T.
Fixes #1118.
Text files modified:
trunk/boost/program_options/detail/value_semantic.hpp | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
Modified: trunk/boost/program_options/detail/value_semantic.hpp
==============================================================================
--- trunk/boost/program_options/detail/value_semantic.hpp (original)
+++ trunk/boost/program_options/detail/value_semantic.hpp 2007-08-05 14:38:07 EDT (Sun, 05 Aug 2007)
@@ -134,7 +134,14 @@
for (unsigned i = 0; i < s.size(); ++i)
{
try {
- tv->push_back(boost::lexical_cast<T>(s[i]));
+ /* We call validate so that if user provided
+ a validator for class T, we use it even
+ when parsing vector<T>. */
+ boost::any a;
+ std::vector<std::basic_string<charT> > v;
+ v.push_back(s[i]);
+ validate(a, v, (T*)0, 0);
+ tv->push_back(boost::any_cast<T>(a));
}
catch(const bad_lexical_cast& /*e*/) {
boost::throw_exception(invalid_option_value(s[i]));
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk