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

Revert part of #676 because there is no implicit conversion to std::string #680

Merged
merged 1 commit into from
Sep 18, 2024
Merged
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
7 changes: 3 additions & 4 deletions include/podio/Frame.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,8 @@ class Frame {
/// is supported by GenericParameters
/// @param key The name under which this parameter should be stored
/// @param value The value of the parameter. A copy will be put into the Frame
template <typename T>
template <typename T, typename = podio::EnableIfValidGenericDataType<T>>
inline void putParameter(const std::string& key, T value) {
static_assert(podio::isSupportedGenericDataType<T>, "Unsupported parameter type");
m_self->parameters().set(key, std::move(value));
}

Expand All @@ -247,8 +246,8 @@ class Frame {
///
/// @param key The name under which this parameter should be stored
/// @param value The value of the parameter. A copy will be put into the Frame
inline void putParameter(const std::string& key, const char* value) {
putParameter<std::string>(key, value);
inline void putParameter(const std::string& key, std::string value) {
putParameter<std::string>(key, std::move(value));
Comment on lines +249 to +250
Copy link
Collaborator

@tmadlener tmadlener Sep 18, 2024

Choose a reason for hiding this comment

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

Just having the std::string and const char* overloads are not enough for catching all implicit conversions? I.e. bring back the std::string overload.

Copy link
Contributor

@m-fila m-fila Sep 18, 2024

Choose a reason for hiding this comment

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

Without SFINAE we get an exact match with a template, only later the conversions would be considered, no?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, without SFINAE the template will always be preferred when the type is not exactly const char* nor std::string, so having both overloads is not enough.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ah right. Overload resolution is fun ;)

}

/// Add a vector of strings value the parameters of the Frame.
Expand Down