1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| #include <vector>
#include <algorithm>
#include <memory>
struct Slot{};
struct Test : public Slot{};
typedef std::shared_ptr<Slot> ptrSlot;
typedef std::vector<ptrSlot> vector_ptrSlot;
typedef std::vector<vector_ptrSlot> matrice_ptrSlot;
int main()
{
matrice_ptrSlot matrice;
matrice.resize(6);
std::for_each(
matrice.begin()
,matrice.end()
,
[](vector_ptrSlot &v_)
{
v_.resize(7);
std::generate(v_.begin(),v_.end(),
[](){return std::shared_ptr<Test>(new Test);}
);
}
);
return 0;
} |