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
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
2 | maomao90 | 163 |
4 | atcoder_official | 161 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | nor | 153 |
9 | Dominater069 | 153 |
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
Название |
---|
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