szaszm commented on a change in pull request #911:
URL: https://github.com/apache/nifi-minifi-cpp/pull/911#discussion_r542328156



##########
File path: libminifi/include/core/FlowFile.h
##########
@@ -129,7 +130,9 @@ class FlowFile : public core::Connectable, public 
ReferenceContainer {
    * @param value value to set
    * @return result of finding key
    */
-  bool getAttribute(std::string key, std::string& value) const;
+  bool getAttribute(const std::string& key, std::string& value) const;
+
+  utils::optional<std::reference_wrapper<const std::string>> 
getAttribute(const std::string& key) const;

Review comment:
       Note: An optional of reference handlers should in general be replaced by 
a non-owning pointer. They have the same semantics, but tooling is better 
equipped to handle pointers.
   
   `auto` generally means safe value semantics, and it becoming a "serious 
misuse" is another footgun that reference types currently have to live with. 
How is this safer otherwise, than returning a const ref or non-owning pointer 
to const?
   
   (I'm continuing because I want to either convince you that this is better or 
understand your standpoint and why I'm wrong.)




----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to