Skip to content

Commit 5f3b9f9

Browse files
committed
decode_json calls reflect::decode_json
1 parent 6c9795a commit 5f3b9f9

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

include/jsoncons/reflect/conv_result.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ class conv_result
4747
conv_result(std::error_code ec) noexcept
4848
: has_value_(false), ec_{ec}
4949
{
50+
::new (&ec_) std::error_code(ec);
5051
}
5152

5253
// copy constructors
@@ -59,7 +60,7 @@ class conv_result
5960
}
6061
else
6162
{
62-
ec_ = other.ec_;
63+
::new (&ec_) std::error_code(other.ec_);
6364
}
6465
}
6566

@@ -73,7 +74,7 @@ class conv_result
7374
}
7475
else
7576
{
76-
ec_ = other.ec_;
77+
::new (&ec_) std::error_code(other.ec_);
7778
}
7879
}
7980

@@ -91,7 +92,7 @@ class conv_result
9192
else
9293
{
9394
destroy();
94-
ec_ = other.ec_;
95+
::new (&ec_) std::error_code(other.ec_);
9596
}
9697
return *this;
9798
}
@@ -105,7 +106,7 @@ class conv_result
105106
else
106107
{
107108
destroy();
108-
ec_ = other.ec_;
109+
::new (&ec_) std::error_code(other.ec_);
109110
}
110111
return *this;
111112
}

include/jsoncons/reflect/decode_traits.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,15 @@ struct decode_traits
5252
{
5353
std::error_code ec;
5454

55-
auto j = try_to_json<basic_json<CharT>>(cursor, ec);
55+
using json_type = basic_json<CharT>;
56+
auto j = try_to_json<json_type>(cursor, ec);
5657
if (ec)
5758
{
5859
return result_type(read_error{ec, cursor.line(), cursor.column()});
5960
}
60-
auto result = reflect::json_conv_traits<decltype(j), value_type>::try_as(j);
61+
auto result = reflect::json_conv_traits<json_type, value_type>::try_as(j);
6162

62-
return result ? result_type{ { std::move(result.value()) } } : result_type{ {result.error(), cursor.line(), cursor.column()} };
63+
return result ? result_type(std::move(result.value())) : result_type(read_error{result.error(), cursor.line(), cursor.column()});
6364
}
6465
};
6566

0 commit comments

Comments
 (0)