on-internet
← Community

Should I use an empty initializer list for C++ containers? [duplicate]

Stack Overflow ·

I was recommended to initialize containers like this: std::vector< int > v = {}; The reason given is that this conforms with initializing all objects in C++, although it is obvious that omitting ={} will call the default constructor. Proponents of this style agree that there is no performance advantage, it is just about style. Is there really an advantage to this? I find that it just adds more characters to process mentally.

Comments

Sign in or sign up to comment and upvote.

No comments yet.