-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enc, Dec: add support for additional standard empty types (std::monostate
and std::nullopt_t
)
#90
Enc, Dec: add support for additional standard empty types (std::monostate
and std::nullopt_t
)
#90
Conversation
647c24d
to
495480e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Please address my comment before merging.
9ad1a75
to
8ffd21d
Compare
@drewdzzz I refactored the patch a bit, please take another look. |
The leftover linting error is a FP fixed in your patch. |
src/Utils/Traits.hpp
Outdated
@@ -638,6 +638,15 @@ template <class T> | |||
constexpr bool is_uni_member_ptr_v = | |||
std::is_member_object_pointer_v<uni_integral_base_t<T>>; | |||
|
|||
struct empty_type { | |||
constexpr empty_type() = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Let's mark it as noexcept
as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, please address a comment.
std::monostate
std::monostate
and std::nullopt_t
(_empty_ types)
std::monostate
and std::nullopt_t
(_empty_ types)std::monostate
and std::nullopt_t
(empty types)
std::monostate
and std::nullopt_t
(empty types)std::monostate
and std::nullopt_t
)
23a3de3
to
32d4186
Compare
src/mpp/Constants.hpp
Outdated
std::nullptr_t, bool, uint64_t, int64_t, float, double, | ||
StrValue, BinValue, ArrValue, MapValue, ExtValue | ||
>; | ||
std::nullptr_t, std::monostate, bool, uint64_t, int64_t, float, double, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about nullopt here?. also I'm afraid of the comment.. I seems that we should not change this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is actually dead code (used in previous codec version), so let's just drop it in a separate commit.
32d4186
to
ae4dacb
Compare
The commit makes clang-format config more suitable to our codebase.
If we are reading a nested type, the return value of `read_item` indicates the number of children the nested type has. However, `read_item` has completely different semantics in case of decoding other types and can even return a completely different non-integer type (the return type is `auto`). Let's put the code in which we rely on the semantics of `read_item` under `if constexpr`.
The `Value_t` definition was used in the previous codec version for abstract value decoding, but now it is unused. Let's drop it so that we don't have to maintain it.
ae4dacb
to
4f6b979
Compare
In addition to `std::nullptr_t`, there are at least 2 more standard empty types, namely `std::monostate` and `std::nullopt_t`, which should correspond to `MP_NIL` in the MsgPack codec. Refactor the codec to support an empty type abstraction, and add `std::monostate` and `std::nullopt_t` to this abstraction. Closes tarantool#82
4f6b979
to
19dc32a
Compare
This patch set brings support for additional standard empty types (
std::monostate
andstd::nullopt_t
) to the MsgPack codec.Closes #82