I think you could consider boost::any. That said, C++ is indeed different from PHP and Python, so are you sure you really need such containers in the first place?