[ 
https://issues.apache.org/jira/browse/MINIFICPP-2254?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marton Szasz updated MINIFICPP-2254:
------------------------------------
    Fix Version/s: 0.16.0

> 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
>            Priority: Minor
>             Fix For: 0.16.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> 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}
> error message in 19.36 (and 19.37):
> {code:java}
> <source>(20): error C2668: '<lambda1>@map_args::operator ()': ambiguous call 
> to overloaded function
> <source>(14): note: could be 'auto <lambda1>@map_args::operator ()<int>(_T3 
> &&) const'
>         with
>         [
>             _T3=int
>         ]
> <source>(16): note: or       'auto <lambda2>@map_args::operator ()<int>(_T4 
> &&) const'
>         with
>         [
>             _T4=int
>         ]
> <source>(20): note: while trying to match the argument list '(int)'
> Compiler returned: 2 {code}
>  



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

Reply via email to