One of the uses of ...
is to denote variadic entities in C and C++.
What is its name?
Is it classified as an operator or something else when used in that way?
Any other details regarding ...
?
Edit: I know the purpose of ...
. I am asking about its name and classification, which I hope, is similar in both C and C++.
It is one of the punctuators .
6.4.6 Punctuators
Syntax punctuator:
one of [ ] ( ) { } . ->
++ -- & * + - ~ !
/ % << >> < > <= >= == != ^ | && ||
? : ; ...
= *= /= %= += -= <<= >>= &= ^= |=
, # ##
<: :> <% %> %: %:%:
In the function declaration it is called the ellipsis .
Ellipsis is also used by some compiler C
language extensions. Example - gcc switch/case range extension
const char *test(unsigned num)
{
switch(num)
{
case 0 ... 9:
return "the value is in the 0 to 9 range";
case 10 ... 99:
return "the value is in the 10 to 99 range";
default:
return "out of tested range";
}
}
...
在英语和 C 标准中都称为省略号。
One of the uses of ... is to denote variadic entities in C and C++.`
Yes, In layman's terms ...
can be thought of as denoting more than one or multiples (as in pseudo-code punctuation we sometimes use multiple dots to resemble different types) of a use case, for which if we consider variadics (being multiple in the sense of 'varying' arguments/parameters) in C++, it would refer to a variable number of arguments for functions or templates.
What is its name?
Ellipsis
Is it classified as an operator or something else when used in that way?
No, it's definitely not an operator as it allows you to pass any number of arguments, not operate on them.
Any other details regarding ...?
As far as I know -
sizeof
operator, as it's classified as a pack expansion as well.Edit: I know the purpose of
...
I am asking about its name and classification, which I hope, is similar in both C and C++.
The name is same, but usage may vary for C++ and C.
Am only familiar with its use in the former language. (I remember having a HackerRank problem on Variadics , covering its utility.)
The sequence of three full stops ...
is called an ellipsis in both C and C++
A parameter pack
- when there is an ellipsis between the type and the identifier Type ... identifier
A pack expansion
- consists of a pattern and an ellipsis pattern...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.