Benefits of Initialization lists

The second version is calling string’s default ctor and then string’s copy-assignment operator — there could definitely be (minor) efficiency losses compared to the first one, which directly calls c’s copy-ctor (e.g., depending on string’s implementation, there might be useless allocation-then-release of some tiny structure). Why not just always use the right way?-)

Leave a Comment