Hacker Newsnew | past | comments | ask | show | jobs | submit | cubbimew's commentslogin

The number of copy/move constructors is zero, by the way, it's not hard (well, could be one if you're using 1980s compilers)


In my recollection, smart pointers were a fairly common C++ idiom in the early 1990s. Ref-counted shared_ptr and scoped_ptr were even proposed in 1994 for standardization, but didn't quite make it (scoped_ptr mutated into auto_ptr). There were also cow, deep-copying, intrusive, and ref-linked smart pointers. It was easy to write your own smart pointer, while GC was something alien and magic.


How is the reference for a library abandoned over 15 years ago even relevant? (other than when researching history)


The guide that's publicly available says "If your class needs to be copyable, prefer providing a copy method, such as CopyFrom() or Clone(), rather than a copy constructor" I think that's insane. Or, at the very least, surprising to encounter when working with someone else's code.


> either people prefer both or prefer neither.

exceptions (specifically, exceptions from constructors) are part of what RAII is, so it's only natural that people "prefer both".

As another personal anecdote, in my experience working with a large (175MLoC at last count) mostly-C++ codebase, I can't imagine how painful it would have been if the code didn't use exceptions.


It doesn't get any worse than that guide (except maybe EC++ or the FQA). No RAII, no class invariants, no value semantics, no streams, no operators (which means no custom Iterators, EqualityComparable or even CopyAssignable types! Such a basic feature called "insidious"). Not even mentioning the FUD about newer C++ features.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: