There are many similar questions and I found both pro and against reasons to use this pattern so I am asking this here:
I need to make a JSON implementation in C++ (
I wouldn't recommend to inherit from STL.
Due to performance reasons STL standard containers do not have virtual destructors, thus you cannot handle them polymorphically.
This means that there's no way to use runtime polymorphisim and expect proper desctructors for them.
Inheriting from STL, although is perfectly allowable, most of the times denotes bad design. I would recommend not following the inherits from way but rather has a way:
namespace JSON {
class JSON { };
class object : public JSON
{
std::unordered_map m;
public:
// provide interface to access m.
};
class Vector : public JSON {
std::vector v;
public:
// provide interface to access v.
};
...
};