Skip to content

Comment on The missing C++ smart pointer

Comments

The author could implement the deep-copying pointer and share the .h on their GitHub. You don’t need a language extension for this in C++ as types can implement operator overrides and copy and move constructors.

But I doubt many people would use it, and that’s probably why it doesn’t belong in std::.

In contrast, before C++ 11, developers would write their own RAII-style smart pointers. So it made sense to save them the labor. I don’t think a pointer that doesn’t allow shallow copies is usually found in codebases. It sounds like a specific use-case pointer.

It’s a neat type that people coming from other languages could like, but maybe not quite standard library-ready?

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.