Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion include/rfl/OneOf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ struct OneOf {
static rfl::Result<T> validate_impl(const T& _value,
std::vector<Error> _errors) {
return Head::validate(_value)
.and_then([&](auto&& _result) -> rfl::Result<T> {
.and_then([&](auto&& /*_result*/) -> rfl::Result<T> {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

While using /*_result*/ to mark a parameter as unused works, using the [[maybe_unused]] attribute is a more modern and clearer way to express this intent in C++17 and later. It makes the code more self-documenting.

Suggested change
.and_then([&](auto&& /*_result*/) -> rfl::Result<T> {
.and_then([&]([[maybe_unused]] auto&& _result) -> rfl::Result<T> {

if constexpr (sizeof...(Tail) == 0) {
if (_errors.size() == sizeof...(Cs)) {
return _value;
Expand Down
2 changes: 1 addition & 1 deletion include/rfl/parsing/FieldVariantParser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct FieldVariantParser {

static schema::Type to_schema(
std::map<std::string, schema::Type>* _definitions,
std::vector<schema::Type> _types = {}) {
std::vector<schema::Type> /*_types = {}*/) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

critical

This change is problematic. By commenting out _types = {}, you have removed the default argument for this parameter. This is a breaking change for any code that calls this function with only one argument. If the parameter is unused but needs to be kept for API compatibility, please use the [[maybe_unused]] attribute to mark it as such while preserving the function signature, including the default argument.

      std::vector<schema::Type> [[maybe_unused]] _types = {}) {

using VariantType = rfl::Variant<NamedTuple<FieldTypes>...>;
return Parser<R, W, VariantType, ProcessorsType>::to_schema(_definitions);
}
Expand Down
2 changes: 1 addition & 1 deletion include/rfl/parsing/Parser_bytestring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct Parser<R, W, Bytestring, ProcessorsType> {
}

static schema::Type to_schema(
std::map<std::string, schema::Type>* _definitions) {
std::map<std::string, schema::Type>* /*_definitions*/) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

While using /*_definitions*/ to mark a parameter as unused works, using the [[maybe_unused]] attribute is a more modern and clearer way to express this intent in C++17 and later. It makes the code more self-documenting.

      std::map<std::string, schema::Type>* [[maybe_unused]] _definitions) {

return schema::Type{schema::Type::Bytestring{}};
}
};
Expand Down
2 changes: 1 addition & 1 deletion include/rfl/parsing/Parser_vectorstring.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ struct Parser<R, W, Vectorstring, ProcessorsType> {
}

static schema::Type to_schema(
std::map<std::string, schema::Type>* _definitions) {
std::map<std::string, schema::Type>* /*_definitions*/) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

While using /*_definitions*/ to mark a parameter as unused works, using the [[maybe_unused]] attribute is a more modern and clearer way to express this intent in C++17 and later. It makes the code more self-documenting.

      std::map<std::string, schema::Type>* [[maybe_unused]] _definitions) {

return schema::Type{schema::Type::Vectorstring{}};
}
};
Expand Down
Loading