changeset 33:793a60620477

Add paragraph about std::optional
author David Demelier <markand@malikania.fr>
date Wed, 18 Jul 2018 13:58:51 +0200
parents 651aee870e36
children 3bf129646979
files STYLE.md
diffstat 1 files changed, 12 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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())