]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#487,!242] Added a note to the Optonal template about required specializations.
authorMarcin Siodelski <marcin@isc.org>
Thu, 28 Feb 2019 10:08:26 +0000 (11:08 +0100)
committerMarcin Siodelski <marcin@isc.org>
Thu, 28 Feb 2019 13:38:18 +0000 (08:38 -0500)
src/lib/util/optional.h

index 3ecb75dadd0b590b0cfe867fe2daf65c738d0aa1..d75787a74b600e5c4d803d49c93489ada1f47e02 100644 (file)
@@ -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) {
     }