Skip to content
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

Merged
merged 5 commits into from
Jan 30, 2024

Conversation

CuriousGeorgiy
Copy link
Member

@CuriousGeorgiy CuriousGeorgiy commented Jan 17, 2024

This patch set brings support for additional standard empty types (std::monostate and std::nullopt_t) to the MsgPack codec.

Closes #82

@CuriousGeorgiy CuriousGeorgiy force-pushed the gh-82-variant-monostate branch 3 times, most recently from 647c24d to 495480e Compare January 17, 2024 13:00
Copy link
Collaborator

@drewdzzz drewdzzz left a 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.

src/mpp/Dec.hpp Show resolved Hide resolved
@drewdzzz drewdzzz assigned CuriousGeorgiy and unassigned drewdzzz Jan 23, 2024
@CuriousGeorgiy CuriousGeorgiy force-pushed the gh-82-variant-monostate branch 3 times, most recently from 9ad1a75 to 8ffd21d Compare January 24, 2024 10:26
@CuriousGeorgiy
Copy link
Member Author

@drewdzzz I refactored the patch a bit, please take another look.

@CuriousGeorgiy
Copy link
Member Author

The leftover linting error is a FP fixed in your patch.

@@ -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;
Copy link
Collaborator

@drewdzzz drewdzzz Jan 24, 2024

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Copy link
Collaborator

@drewdzzz drewdzzz left a 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.

@drewdzzz drewdzzz assigned CuriousGeorgiy and unassigned drewdzzz Jan 24, 2024
@CuriousGeorgiy CuriousGeorgiy changed the title Enc, Dec: add support for std::monostate Enc, Dec: add support for std::monostate and std::nullopt_t (_empty_ types) Jan 25, 2024
@CuriousGeorgiy CuriousGeorgiy changed the title Enc, Dec: add support for std::monostate and std::nullopt_t (_empty_ types) Enc, Dec: add support for std::monostate and std::nullopt_t (empty types) Jan 25, 2024
@CuriousGeorgiy CuriousGeorgiy changed the title Enc, Dec: add support for std::monostate and std::nullopt_t (empty types) Enc, Dec: add support for additional standard empty types (std::monostate and std::nullopt_t) Jan 25, 2024
@CuriousGeorgiy CuriousGeorgiy force-pushed the gh-82-variant-monostate branch 5 times, most recently from 23a3de3 to 32d4186 Compare January 29, 2024 08:24
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,
Copy link
Contributor

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.

Copy link
Member Author

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.

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.
@CuriousGeorgiy CuriousGeorgiy force-pushed the gh-82-variant-monostate branch from ae4dacb to 4f6b979 Compare January 30, 2024 12:44
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
@CuriousGeorgiy CuriousGeorgiy force-pushed the gh-82-variant-monostate branch from 4f6b979 to 19dc32a Compare January 30, 2024 12:50
@alyapunov alyapunov merged commit 5b7daa1 into tarantool:master Jan 30, 2024
37 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support std::monostate
3 participants