DEV Community

Discussion on: That `overloaded` Trick: Overloading Lambdas in C++17

maxxon profile image

It's not a non-member helper template, it's a user defined deduction guide. See this article:

Thread Thread
misiaszek profile image
Marcin Misiaszek

It works also without deduction guide and the 'using' fix is for g++. 'operator()' cannot be ambiguous in visitors but gcc is very careful with overloading derived functions. In clang we can easily have the same results with minimal code (checked output assembler with Compiler Explorer):

template<class... Ts> struct overload : Ts... {
  overload(Ts...) = delete;

There is needed aggregate Initialisation + variadic templates.