docs: update code-style rule 2.24
This commit also updates existing code to use the new format.
refs #4681
Change-Id: I88e62a34fc55a69cd01d74e80a7000c6cf4d7c2d
diff --git a/docs/code-style.rst b/docs/code-style.rst
index 0ae08fc..7071e1d 100644
--- a/docs/code-style.rst
+++ b/docs/code-style.rst
@@ -682,12 +682,16 @@
class Foo
{
+ public:
class Error : public std::runtime_error
{
public:
- explicit
- Error(const std::string& what)
- : std::runtime_error(what)
+ // You can inherit constructors from std::runtime_error like this:
+ using std::runtime_error::runtime_error;
+
+ // Additional constructors, if desired, can be declared like this:
+ Error(const std::string& what, const std::exception& inner)
+ : std::runtime_error(what + ": " + inner.what())
{
}
};