-
Notifications
You must be signed in to change notification settings - Fork 60
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
Fix compilation errors with Clang v16+. Also includes fixes for compiling with -std=c++23. #498
Conversation
compiling with -std=c++23.
@@ -187,7 +187,7 @@ namespace sparta::pipeViewer | |||
if(!dat.stringVector[i].empty()){ | |||
// We check if we have seen this exact pair, field and value before or not. | |||
if(const auto& [val, str] = std::tie(dat.valueVector[i].first, dat.stringVector[i]); | |||
stringMap.try_emplace(std::make_tuple(dat.pairId, i, val), str).second) { | |||
stringMap.emplace(std::piecewise_construct, std::forward_as_tuple(dat.pairId, i, val), std::forward_as_tuple(str)).second) { |
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.
Workaround for a Clang bug: llvm/llvm-project#61415
This is essentially what try_emplace
does under the hood, so performance shouldn't be affected.
@@ -95,7 +95,7 @@ namespace sparta | |||
*/ | |||
struct DataPointer { | |||
private: | |||
typename std::aligned_storage<sizeof(value_type), alignof(value_type)>::type object_memory_; | |||
alignas(value_type) std::byte object_memory_[sizeof(value_type)]; |
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.
std::aligned_storage
was deprecated in C++23: https://stackoverflow.com/questions/71828288/why-is-stdaligned-storage-to-be-deprecated-in-c23-and-what-to-use-instead
@@ -27,56 +27,56 @@ | |||
/*! | |||
* \brief Custom literal for uint64 | |||
*/ | |||
constexpr inline uint64_t operator "" _u64(unsigned long long i) { | |||
constexpr inline uint64_t operator ""_u64(unsigned long long i) { |
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.
Clang throws a compiler error if there is a space between the ""
and the _
ArchiveNode::ArchiveNode(const std::string & name) : | ||
name_(name) | ||
{ | ||
} | ||
|
||
ArchiveNode::~ArchiveNode() | ||
{ | ||
} | ||
|
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.
Moving these to the .cpp
file helps avoid some pitfalls when you use an incomplete type with a smart pointer.
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.
Nice cleanup!
This PR fixes compilation errors I observed trying to compile with clang v16 and v17, as well as some errors from bumping the C++ standard to C++23.