Skip to content

Commit 787cd37

Browse files
committed
optional<T> is now parsable, even if T is a class type.
1 parent ced0f5c commit 787cd37

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

parse/jsd_optional.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,13 @@ namespace JSON
1010
PropertyTree const& object, ParsingOptions const& options = DEFAULT_PARSER_OPTIONS)
1111
{
1212
try
13-
{
14-
auto opt = object.tree.get_optional <T> (name);
15-
if (!opt)
16-
return; // its ok, it was optional
17-
else
18-
value = opt.get();
13+
{
14+
if (object.tree.get_optional <std::string> (name))
15+
{
16+
T v;
17+
parse(v, name, object, options);
18+
value = v;
19+
}
1920
}
2021
catch (boost::property_tree::ptree_bad_data& exc)
2122
{

0 commit comments

Comments
 (0)