You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A unique_ptr<node> is no longer a node—it’s a unique_ptr masquerading as a node. It’s preferable to retain the type of node*, and retain the properties of node*-ness that go along with it, because we don’t really actually care about unique_ptr for its own sake.
This is technically wrong. The type named node* is never equivalent to the type node in C or C++, neither. The * declarator in C or C++ is essentially another masquerading unary type constructor. It is actually aliased as something like std::add_pointer_t in modern C++. There is nothing new about "masquerading" once you can have parametric types in general, either with std::add_pointer_t<node> or node*.
You seem to have intention of preferring to the default typing discipline with less type safety guarantees (e.g. about unexpected subtyping between some_raw_ptr<node> vs some_owned_ptr<node>), but it is not reasonable from the description here.
Besides type safety and verbosity, there remains probably only one significant difference: * is built in the core language. This is just because it comes from the language without uniformed syntax of type constructor like C++ template, which is irrelevant here.
The text was updated successfully, but these errors were encountered:
This is technically wrong. The type named
node*
is never equivalent to the typenode
in C or C++, neither. The*
declarator in C or C++ is essentially another masquerading unary type constructor. It is actually aliased as something likestd::add_pointer_t
in modern C++. There is nothing new about "masquerading" once you can have parametric types in general, either withstd::add_pointer_t<node>
ornode*
.You seem to have intention of preferring to the default typing discipline with less type safety guarantees (e.g. about unexpected subtyping between
some_raw_ptr<node>
vssome_owned_ptr<node>
), but it is not reasonable from the description here.Besides type safety and verbosity, there remains probably only one significant difference:
*
is built in the core language. This is just because it comes from the language without uniformed syntax of type constructor like C++ template, which is irrelevant here.The text was updated successfully, but these errors were encountered: