News for hackers. Stuff that matters.
Re:Why I Write Games in C (yes, C) by Pombal on Sunday September 22, 2019 @08:10AM (#21040982)
Yes, really. It's fine for simple types but for more complex types in more complex situations, you pay the price.

Unique pointers carry around not just the type but also a default deleter, if you provide one. That deleter has to be copied around, checked for nullptr before execution and set to nullptr when ownership changes.

For even more examples of this have a look at this talk when it comes out: https://cppcon2019.sched.com/event/Sfq4/there-are-no-zero-co...

Re:Why I Write Games in C (yes, C) by rcxdude on Sunday September 22, 2019 @09:40AM (#21041307)
Only if the deleter you define has any state, which is very rare and in that case you would need to copy that data around anyway...

(for example: https://gcc.godbolt.org/z/mU7hub)

Re:Why I Write Games in C (yes, C) by pingyong on Monday September 23, 2019 @09:00AM (#21048479)
It's pretty stupid to compare a unique_ptr with a deleter that contains state to a pointer - obviously those two things are completely different and the unique_ptr contains way more information.