From: Marcin Siodelski Date: Thu, 28 Feb 2019 10:08:26 +0000 (+0100) Subject: [#487,!242] Added a note to the Optonal template about required specializations. X-Git-Tag: 478-improve-error-message-database-backend-mysql_base~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4d1dae1addd573e479f01bc10e89caa5296dfcb9;p=thirdparty%2Fkea.git [#487,!242] Added a note to the Optonal template about required specializations. --- diff --git a/src/lib/util/optional.h b/src/lib/util/optional.h index 3ecb75dadd..d75787a74b 100644 --- a/src/lib/util/optional.h +++ b/src/lib/util/optional.h @@ -75,6 +75,19 @@ public: /// @brief Default constructor. /// /// Sets the encapsulated value to 0 and marks it as "unspecified". + /// + /// The caller must ensure that the constructor of the class @c T + /// creates a valid object when invoked with 0 as an argument. + /// For example, a @c std::string(0) compiles but will crash at + /// runtime as 0 is not a valid pointer for the + /// @c std::string(const char*) constructor. Therefore, the + /// specialization of the @c Optional template for @c std::string + /// is provided below. It uses @c std::string default constructor. + /// + /// For any other type used with this template which doesn't come + /// with an appropriate constructor, the caller must create a + /// template specialization similar to the one provided for + /// @c std::string below. Optional() : default_(T(0)), unspecified_(true) { }