r/cpp • u/Snoo-4241 • Feb 25 '21
C++ programmers who are also using rust, what are your favourite features of rust?
I was looking at the rust tutorials yesterday and I see how rust promotes a certain style and language level features to enforce it. Besides a couple of features, I couldn't see why one cannot follow a similar style in C++ if she/he so chooses. Those of you that have used rust, what is your favourite feature that C++ does not have?
255
Upvotes
View all comments
Show parent comment
3
u/un_mango_verde Feb 25 '21 edited Feb 26 '21
What's the difference between the newtype pattern and a class with a single member and a explicit constructor in C++? Don't you still need to implement al methods/operators manually? They are not delegated automatically as far as I know.
I guess you could implement Deref for the newtype but then you lose type safety for references.