-
Notifications
You must be signed in to change notification settings - Fork 37
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
Add a header with constants #234
Conversation
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.
Thanks!
include/edm4hep/Constants.h
Outdated
#ifndef EDM4HEP_CONSTANTS_H | ||
#define EDM4HEP_CONSTANTS_H | ||
|
||
#include <string> |
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.
#include <string> | |
#include <string_view> |
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.
Actually if we make it const char*
we don't need any include here.
include/edm4hep/Constants.h
Outdated
#include <string> | ||
|
||
namespace edm4hep { | ||
inline constexpr std::string_view CellIDEncoding = "CellIDEncoding"; |
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.
inline constexpr std::string_view CellIDEncoding = "CellIDEncoding"; | |
inline static constexpr auto CellIDEncoding = "CellIDEncoding"; |
I think making this a static const char*
makes it easier to consume for things that take a const std::string&
as a string_view
will lead to
error: invalid initialization of reference of type 'const std::string&' {aka 'const std::__cxx11::basic_string<char>&'} from expression of type 'const std::string_view' {aka 'const std::basic_string_view<char>'
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 will also still work if functions take a string_view
as argument.
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.
I made it const char*
(explicit in case someone checks the header); inline
can be dropped since it's static
Useful for HEP-FCC/k4SimGeant4#55 and key4hep/k4EDM4hep2LcioConv#32 and other places so that we can set the same value in all places consistently.
More constants can be added if there are suggestions.
BEGINRELEASENOTES
ENDRELEASENOTES