Search code examples
c++operators

what is the use of ... in c++


I tried googling ... but as expected, google ignored it.

I have this code :

try {

// some code
}

catch( ... ) {
// catch logic

}

I'm guessing that ... means any kind of exceptions, am I right ?
any other usages for this ?


Solution

  • I am aware of three use cases:

    • Variable number of arguments like 'printf(const char* fmt, ...)'
    • A catch anything as 'catch(...)'
    • A variadic template like 'template < typename ...T >' and unpacking 'T ...' (c++11)

    And another one, which I missed, is preprocessing: variadic macros