szaszm commented on code in PR #1612:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1612#discussion_r1270402865
##########
libminifi/include/utils/FlatMap.h:
##########
@@ -138,7 +134,9 @@ class FlatMap{
return data_.size();
}
- V& operator[](const K& key) {
+ template<typename T>
+ requires std::constructible_from<K, T> && std::equality_comparable_with<K, T>
Review Comment:
Why do we need `constuctible_from`? If we really need it, are we really
interested in constructing K from an object of T?
##########
extensions/libarchive/CompressContent.cpp:
##########
@@ -88,7 +88,7 @@ void CompressContent::processFlowFile(const
std::shared_ptr<core::FlowFile>& flo
std::string attr;
flowFile->getAttribute(core::SpecialFlowAttribute::MIME_TYPE, attr);
if (attr.empty()) {
- logger_->log_error("No %s attribute existed for the flow, route to
failure", core::SpecialFlowAttribute::MIME_TYPE);
+ logger_->log_error("No %s attribute existed for the flow, route to
failure", core::SpecialFlowAttribute::MIME_TYPE.data());
Review Comment:
This is unsafe, unless you can guarantee that after the end of the
pointed-to string span, there is a null byte. I'm not sure what the standard
requires for string_views initialized from plain old string literals. ("Works
on my compiler" is not safe enough.)
##########
libminifi/include/utils/FlatMap.h:
##########
@@ -282,20 +290,18 @@ class FlatMap{
return data_.max_size();
}
- bool empty() const noexcept {
+ [[nodiscard]] bool empty() const noexcept {
return data_.empty();
}
- bool contains(const K& key) const {
+ template<typename T>
+ requires std::equality_comparable_with<K, T>
+ bool contains(const T& key) const {
Review Comment:
```suggestion
bool contains(std::equality_comparable_with<K> auto const& key) const {
```
##########
libminifi/include/utils/FlatMap.h:
##########
Review Comment:
I would keep the overloads taking the key type, and only add the new
functionality as new overloads.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]