Ferenc Gerlits created MINIFICPP-2254:
-----------------------------------------

             Summary: Simplify template used by log_format_string to make 
VS2022 understand it
                 Key: MINIFICPP-2254
                 URL: https://issues.apache.org/jira/browse/MINIFICPP-2254
             Project: Apache NiFi MiNiFi C++
          Issue Type: Bug
            Reporter: Ferenc Gerlits
            Assignee: Ferenc Gerlits


The {{map_args}} class template used by the {{log_format_string}} class 
template in Logger.h uses some tricky template magic so that we can call the 
logger both with invocable objects and plain value objects.

This template magic compiled fine in VS2019, as well as VS2022 up to version 
19.35. However, since version 19.36, it no longer compiles.

 
{code:java}
#include <concepts>
#include <type_traits>

template<typename... Funcs>struct overloaded : Funcs... {
  using Funcs::operator()...;
};

// deduction guide. doesn't hurt, but doesn't help either
//template<typename... Funcs>//overloaded(Funcs...) -> overloaded<Funcs...>;

const auto inline map_args = overloaded {
    [](std::invocable<> auto&& f) { return 
std::invoke(std::forward<decltype(f)>(f)); },  // works in 19.35, fails in 19.36
//  [](auto&& f) requires(std::is_invocable_v<decltype(f)>) { return 
std::invoke(std::forward<decltype(f)>(f)); },  // this works in both
    [](auto&& value) { return std::forward<decltype(value)>(value); }
};

int main() {
    return map_args(int());
}
{code}
 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to