Search code examples
c++variadic-templatesc++20

Using struct constructor to create an struct instance in C++


I am trying to wrap my mind around this talk: https://www.youtube.com/watch?v=FXfrojjIo80 I get an error on the following part. It is the simplified version.

template<typename... Ts>
struct parms : Ts... {};

template<typename... Ts>
parms(Ts... ) -> parms<Ts...>;

struct first{};
struct second{};

int main(int argc, char *argv[])
{   
    parms p(first{}, second{});  
}

I get a compile error on clang but compiles on gcc. Which C++ feature is this that is not supported in clang? Obviously if i change the ( to { it compiles fine.


Solution

  • Cppreference aptly calls it "Parenthesized initialization of aggregates".