cpp version:

* remove std::shared_ptr dependency
* add size()
* misc changes