Which one of the following is preferred/more efficient?
Initialization list:
class Trial { private: std::vector<int> _vec; public: Trial(size_t length) : _vec(length) { } };
Resize:
class Trial { private: std::vector<int> _vec; public: Trial(size_t length) { _vec.resize(length); } };
I've seen both in production code, but I've also heard that if you can delegate some work to the compiler, you should, so I always preferred the first one.
Is one of them better than the other?