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

Typedfield has bad move constructor #4567

Merged
merged 1 commit into from
Jun 26, 2023
Merged
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
8 changes: 1 addition & 7 deletions src/ripple/protocol/SField.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,13 +273,7 @@ struct TypedField : SField
using type = T;

template <class... Args>
explicit TypedField(Args&&... args) : SField(std::forward<Args>(args)...)
{
}

TypedField(TypedField&& u) : SField(std::move(u))
{
}
explicit TypedField(private_access_tag_t pat, Args&&... args);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we still need the explicit keyword? Won't the private_access_tag_t prevent the compiler from using implicit type conversion?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Not if the parameter pack is empty, which it likely never will be in practice, but explicit doesn't hurt.

Copy link
Collaborator

Choose a reason for hiding this comment

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

hmm, that's crazy, i didn't know that! that pulls the rug under the purpose of having the private tag :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's no real motivation to allow implicit construction as it is only constructed in one file, and even that is handled by a macro.

};

/** Indicate std::optional field semantics. */
Expand Down
7 changes: 7 additions & 0 deletions src/ripple/protocol/impl/SField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ struct SField::private_access_tag_t

static SField::private_access_tag_t access;

template <class T>
template <class... Args>
TypedField<T>::TypedField(private_access_tag_t pat, Args&&... args)
: SField(pat, std::forward<Args>(args)...)
{
}

// Construct all compile-time SFields, and register them in the knownCodeToField
// database:

Expand Down