moving from c++ to D is easy?

Namespace via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Mar 12 13:19:57 PDT 2015


On Thursday, 12 March 2015 at 18:57:51 UTC, Ali Çehreli wrote:
> On 03/12/2015 06:01 AM, ayush wrote:
>
> > Is D a lot like c++ ?
>
> I came to D from C++. I remember the following being notable 
> differences:
>
> - In D, classes have reference semantics. I quickly realized 
> that this is not an issue because so many of my C++ types were 
> hand-reference-typified :p by this idiom, almost everywhere:
>
> class C { /* ... */ };
> typedef boost::shared_ptr<C> CPtr;
> void foo(CPtr c);

This is a common mistake. In 99 percent of cases you want to use 
a std::unique_ptr. std::shared_ptr is rarely common and often an 
indication of an error in design. In general, there is exactly 
one owner only.
But I think you know that already. :)


More information about the Digitalmars-d-learn mailing list