but one of the really nice feature coming in the C++11 standard is the "initializer list".
In fact with C++11, you can now write:
std:vector
see http://en.wikipedia.org/wiki/C%2B%2B11#Core_language_usability_enhancements
But if you are still using the old C++, you can at least try to avoid the push_back usage...
Instead of writing
std:vector
vec.push_back("blog");
vec.push_back("msg");
let's use Boost/Assign to offer a += operator supporting variable number of arguments
#include "boost/assign.hpp"
std:vector
vec += "blog", "msg";
Aucun commentaire :
Enregistrer un commentaire