Hello programmers,,
I read someones code a couple days earlier and i saw a piece of code using __typeof operator as a shortcut of a for loop. What is this operator and can it be used ?? Thanks :D
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Hello programmers,,
I read someones code a couple days earlier and i saw a piece of code using __typeof operator as a shortcut of a for loop. What is this operator and can it be used ?? Thanks :D
Name |
---|
Before the C++11 standard it was a function in GNU C++, that returns type of argument. For example:
It was removed in C++11 because of
auto
."replace" would be more appropriate word here, because typeof is not a nomral C function. it is more of a pre-compiler replacement (well, like, macros)
Actually it was replaced by
decltype
, notauto
.Yes i started using auto and it was more practical and easier than iterators Thank you :D
adamant seems to have the answer as to what it does. i would like to add that
typeof
(not__typeof
, btw) is not a C/C++ operator, but a compiler extension provided by GCC (which means it does not work on some other compilers).Im using VS 2013 and the syntax is __typeof But the problem is that it keeps telling me that "identifier is undefined" Do you have any explanation ??
i'm not very sure about VS 2013 interface; u can ask others who use it. i use Sublime Text 2 as my editor and Ubuntu Terminal to compile and run the code.
but i can tell u that in my template (from any of my recent submissions) i have the following line.
#define TR(i,x) for(typeof(x.begin()) i=x.begin();i!=x.end();i++)
here u can see that i use
typeof()
(i should change it toauto
from now), not__typeof
. this compiles and runs very well.I started using auto like the one you mentioned earlier. Any way auto worked just fine,and there is no need to change it into typeof. Thank you for your help :D
namedir oytyan? name bolsa gowy? wiii yatdan cykypdyr son gulerin