Note that there are some explanatory texts on larger screens.

plurals
  1. USJonathan M Davis
    primarykey
    data
    text
    plurals
    1. COSo, really, it's a deficiency in the language, not the compiler. Some compiler writers chose to break the standard in order to get around that deficiency (which is handy if that's the only compiler you use but otherwise hurts portability and causes problems), while others chose to follow the standard. Fortunately, the next standard fixes this deficiency in the language so that it will no longer be an issue. I really wouldn't say that it's a deficiency in the compilers though, since that's the way the current standard is.
      singulars
    2. COGenerally speaking, any operation which alters a `vector` rather than an element in the `vector` could invalidate all iterators for that `vector`. So, it's generally a bad idea to alter a `vector` while iteratoring over it or needing to save any iterators to it. However, some operations - such as `erase()` - return a valid iterator to the next element, so it's possible to alter a `vector` in such situations and still have valid iterators, but you have to be careful with what you're doing or you can shoot yourself in the foot.
      singulars
    3. CO@Konrad Most likely. But if you're compiler isn't inlining (and I don't think that gcc does short of -O3 - certainly that's when it starts using the -inline flag), then it won't inline. If you're compiler is doing inline optimizations, then yes it _will_ happen as long as length() is declared inline - which presumably it is. But if inlining isn't turned on in your compiler, then you're going to incur the cost.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload