adamdebreceni commented on a change in pull request #1267:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1267#discussion_r814556193



##########
File path: libminifi/include/core/logging/Logger.h
##########
@@ -53,28 +54,32 @@ class LoggerControl {
   std::atomic<bool> is_enabled_;
 };
 
-inline char const* conditional_conversion(std::string const& str) {
-  return str.c_str();
-}
+template<typename Arg>
+using has_const_c_str_method = decltype(std::declval<const Arg&>().c_str());
 
-template<size_t N>
-inline char const* conditional_conversion(const utils::SmallString<N>& arr) {
-  return arr.c_str();
+template<typename Arg>
+inline decltype(auto) conditional_stringify(Arg&& arg) {
+  if constexpr (utils::meta::is_detected_v<has_const_c_str_method, Arg> || 
std::is_scalar_v<std::decay_t<Arg>>) {
+    return std::forward<Arg>(arg);
+  } else if constexpr (std::is_invocable_v<Arg>) {
+    return std::forward<Arg>(arg)();

Review comment:
       since we call `std::is_invocable_v` with zero arguments, it is exactly 
the zero argument callable FunctionObjects it is checking for




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


Reply via email to