Skip to content

Comment on C++ to Rust Phrasebookparent

Comments

Right, when construction is fallible you need a factory.

Constructors are called in surprising places when running a C++ program. For example, think of a copy constructor failing somewhere far away from the code you are writing. If C++ allowed construction to fail, the control flow of propagating these errors would be tedious and invasive.

Hence exceptions as the only way to fail in a construction.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.