Skip to content

Commit

Permalink
Added more explicit type casts
Browse files Browse the repository at this point in the history
  • Loading branch information
liuzicheng1987 committed Dec 21, 2024
1 parent c3eb17a commit 070154b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/rfl/parsing/Parser_optional.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ struct Parser<R, W, std::optional<T>, ProcessorsType> {
if constexpr (schemaful::IsSchemafulWriter<W>) {
auto u = ParentType::add_union(_w, _parent);
using UnionType = typename ParentType::template Union<decltype(u)>;
auto p = UnionType{.index_ = _o ? 0 : 1, .union_ = &u};
auto p =
UnionType{.index_ = static_cast<size_t>(_o ? 0 : 1), .union_ = &u};
if (_o) {
Parser<R, W, std::remove_cvref_t<T>, ProcessorsType>::write(_w, *_o, p);
} else {
Expand Down
3 changes: 2 additions & 1 deletion include/rfl/parsing/Parser_shared_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ struct Parser<R, W, std::shared_ptr<T>, ProcessorsType> {
if constexpr (schemaful::IsSchemafulWriter<W>) {
auto u = ParentType::add_union(_w, _parent);
using UnionType = typename ParentType::template Union<decltype(u)>;
auto p = UnionType{.index_ = _s ? 0 : 1, .union_ = &u};
auto p =
UnionType{.index_ = static_cast<size_t>(_s ? 0 : 1), .union_ = &u};
if (_s) {
Parser<R, W, std::remove_cvref_t<T>, ProcessorsType>::write(_w, *_s, p);
} else {
Expand Down
3 changes: 2 additions & 1 deletion include/rfl/parsing/Parser_unique_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ struct Parser<R, W, std::unique_ptr<T>, ProcessorsType> {
if constexpr (schemaful::IsSchemafulWriter<W>) {
auto u = ParentType::add_union(_w, _parent);
using UnionType = typename ParentType::template Union<decltype(u)>;
auto p = UnionType{.index_ = _s ? 0 : 1, .union_ = &u};
auto p =
UnionType{.index_ = static_cast<size_t>(_s ? 0 : 1), .union_ = &u};
if (_s) {
Parser<R, W, std::remove_cvref_t<T>, ProcessorsType>::write(_w, *_s, p);
} else {
Expand Down

0 comments on commit 070154b

Please sign in to comment.