4 ms·
it is easy? It is the named constructor idiom. I don't understand why jupp0r is getting downvoted? Most big public c++ projects turn off exceptions, so it see
by kwant_kiddo 3y ago
it is easy? It is the named constructor idiom.
I don't understand why jupp0r is getting downvoted?
Most big public c++ projects turn off exceptions, so it seems to be the norm more than anything.
- gpderetta 3y agoBecause two phase construction is a widely disliked idiom. Named constructors retuning optional objects are tolerable though.
- jupp0r 3y agoTwo phase construction isn't widely disliked, it's completely fine if it's used as an implementation detail of a factory.
- pjmlp 3y agoOnly the big public C++ projects that blindly follow Google's style guide, mostly.
- kwant_kiddo 3y agoI don't think this is true, but I don't know this for sure. From what I have read it seems that 'only' Bloomberg, Meta and Microsoft that uses c++ with exceptions. And since both microsoft and meta are adopting rust in their services it seems to me that they are looking for another language than C++. (why else adopt a new language?) Following seems not to use exceptions(?) LLVM: https://llvm.org/docs/CodingStandards.html#do-not-use-rtti-or-exceptions https://llvm.org/docs/CodingStandards.html#do-not-use-rtti-o... AWS: (seems to be using Google's guidelines to be fair) Webkit: https://gist.github.com/derofim/df604f2bf65a506223464e3ffd96a78a https://gist.github.com/derofim/df604f2bf65a506223464e3ffd96... Qt: https://doc.qt.io/qt-6/exceptionsafety.html https://doc.qt.io/qt-6/exceptionsafety.html gcc: https://gcc.gnu.org/codingconventions.html#Exceptions https://gcc.gnu.org/codingconventions.html#Exceptions Unreal: (not totally sure, but I think it uses error codes internally) Most of the embedded world. + any console game you ever played or heard of.
- pjmlp 3y agoLLVM has been for quite some time driven by Apple and Google. WebKit, another Apple child. Qt, it has to support environments where exceptions are not allowed, otherwise they would be losing customers, specially since Qt is older than C++98. gcc, was initially written in C, and for quite long time had a mixed code base with minimal C++. The companies adopting Rust aren't doing so because of lack of exceptions, they would still adopt Rust if the language had exceptions support (which panic and std::ops::Try kind of are), rather due to the type safety that C and C++ aren't able to provide. You would be surprised how many games actually do support exceptions.