4 ms·
It took you 6 years before you touched std? what std are you talking? as in the namespace std::cout, std::cin, etc?
by victorhn 14y ago
It took you 6 years before you touched std? what std are you talking? as in the namespace std::cout, std::cin, etc?
- speeder 14y agoyes. I still don`t use cout and cin actually. I prefer printf. I don`t know what are streams exactly (but I bought Bjarne TC++PL and it will arrive next thursday, and then I will read what it is...) In fact, I still rarely use std, when I use it is vectors. I never used std interators (I think they are fugly, and I like to use while() instead of for ) And I don`t know what else std do beside iterators, streams and containers.
- tgflynn 14y agoAs far as the C++98 standard library goes I think vectors are by far the most useful construct it provides because they're like arrays but manage memory for you. Lot's of people prefer printf to cout/cin. Iterators in my opinion are a bad idea because there are so many cases when you need to do index arithmetic. The idea of having common interfaces for data structures with very different performance characteristics is one that probably seemed great to some people at the time but it doesn't work too well in practice. The C++11 standard library seems to have a lot more features that may be very useful, like regular expressions, but I haven't started using it yet and if you care about cross-platform code it probably won't be truly useable for several years. EDIT: Had a nagging feeling I was forgetting something when I wrote this. Yes of course std::map is incredibly useful it's definitely something one would need to implement if it weren't in the library.
- pcowans 14y agoAlthough I kind of agree with you that iterators for vectors aren't really very necessary, for std::list, std::map, etc. I think they're quite a sensible way of sequentially accessing the data - you'd pretty much have to re-implement them if they didn't exist. In the case of maps, I don't actually think the container implementation is specified enough to allow you to get away with any less abstraction - it technically doesn't have to be a BST, although I guess you could argue that the containers should have mapped to precisely defined data structures in the first place. C++11's type inference does make STL iterators a lot less ugly, by the way. Also (referring to the initial post), there's no reason you have to use for rather than while when using iterators (while(v != c.end()) ...).