I guess that depends on the definition of "smart pointer". I haven't found any "official" definition (e.g. in the reference) yet. But what I found is this:
That's from the official documentation. Of course, there is only a "should" and not a "must" there, and Deref
is also implemented for plain references.
I would even claim that Cow::Owned
can could (on a high abstraction level) be considered a smart pointer. It's not much different than Box
, except that the value lives on the stack instead of the heap, right? If we disregard the underlying memory management, it's not much different from Box
.
P.S.: Actually the inner type of a I guess Cow
is ?Sized
.then it then matters where the Cow
is used whether the storage happens on the heap or stack (but in the same space where the Cow lives, which may be an argument to say there is no "indirection"). (The inner type of a Cow
is ?Sized
.)
P.P.S.: I also understand the intuition that String
isn't a smart pointer (again without wanting to say it isn't either). I guess without any clear definition, everyone can have their own definition. It's still interesting (for me) to understand what the term usually means, and @trentj's note that the term originates from operator overloading in C++ was interesting.