Subject: Re: [Boost-bugs] [Boost C++ Libraries] #7495: Support for boost::optional in boost::program_options
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2015-10-30 10:44:57
#7495: Support for boost::optional in boost::program_options
------------------------------------------+-----------------------------
Reporter: Dmitry Trifonov <user61a@â¦> | Owner: vladimir_prus
Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: program_options
Version: Boost 1.52.0 | Severity: Optimization
Resolution: | Keywords:
------------------------------------------+-----------------------------
Comment (by Edward Catmur <ed@â¦>):
Implementing optional support via streaming would have unwanted side
effects. The correct place to implement optional support is via the
validate customization point:
{{{
namespace boost {
template<class T>
void validate(boost::any& v, std::vector<std::string> const& values,
boost::optional<T>* typeTag, int)
{
if (!values.empty())
{
boost::any a;
using namespace boost::program_options;
validate(a, values, (T*)0, 0);
v = boost::any(boost::optional<T>(boost::any_cast<T>(a)));
}
}
}
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/7495#comment:5> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:19 UTC