Home > Enterprise >  what is `typename...` syntax in C template?
what is `typename...` syntax in C template?

Time:11-26

Just found this piece of code in a Program(C ) file:

template <typename blah, typename... Args>
const <some-type> bof(<some-parameters>, Args&&... args) const
{
    return breck(std::forward<Args>(args)...);
}

I am wondering:

  1. what is the three dots after the typename?
  2. Intuitively looks like in this way we can pass multiple arguments? Looking for some official term/reference for it?

CodePudding user response:

It is called parameter pack, you can read more here: https://en.cppreference.com/w/cpp/language/parameter_pack

Indeed, you can use Args... for unpacking multiple arguments in function or class templates, when you don't know ahead of time how many templated parameters there is going to be.

  • Related