Add paragraph about std::optional

Wed, 18 Jul 2018 13:58:51 +0200

author
David Demelier <markand@malikania.fr>
date
Wed, 18 Jul 2018 13:58:51 +0200
changeset 33
793a60620477
parent 32
651aee870e36
child 34
3bf129646979

Add paragraph about std::optional

STYLE.md file | annotate | diff | comparison | revisions
--- a/STYLE.md	Wed Jul 18 13:55:49 2018 +0200
+++ b/STYLE.md	Wed Jul 18 13:58:51 2018 +0200
@@ -431,6 +431,18 @@
 ```cpp
 const std::string_view version("1.0");
 
+void load(std::string_view id, std::string_view path)
+{
+    std::cout << "loading: " << id << " from path: " << path << std::endl;
+}
+```
+
+### Optional values
+
+Use `std::optional` to indicate a null value considered as valid. For example,
+searching a value that may not exist.
+
+```cpp
 auto find(std::string_view id) -> std::optional<int>
 {
     if (auto it = foo.find(id); it != foo.end())

mercurial