]> git.stg.codes - stg.git/blobdiff - projects/sgconf/utils.h
Fight Optional
[stg.git] / projects / sgconf / utils.h
index 6168cbf2f111354fb44969bacc250e8485e6d7dc..3a57d9995f9f5b74c437703f65f73741f4aea2b0 100644 (file)
@@ -1,45 +1,45 @@
 #pragma once
 
 #include "stg/common.h"
-#include "stg/optional.h"
 
 #include <string>
 #include <map>
+#include <optional>
 
 namespace SGCONF
 {
 
 template <typename T>
 inline
-void MaybeSet(const std::map<std::string, std::string> & options, const std::string & name, STG::Optional<T> & res)
+void MaybeSet(const std::map<std::string, std::string> & options, const std::string & name, std::optional<T> & res)
 {
-std::map<std::string, std::string>::const_iterator it(options.find(name));
-if (it == options.end())
-    return;
-T value;
-if (str2x(it->second, value) < 0)
-    return;
-res = value;
+    std::map<std::string, std::string>::const_iterator it(options.find(name));
+    if (it == options.end())
+        return;
+    T value;
+    if (str2x(it->second, value) < 0)
+        return;
+    res = value;
 }
 
 template <typename T, typename F>
 inline
 void MaybeSet(const std::map<std::string, std::string> & options, const std::string & name, T & res, F conv)
 {
-std::map<std::string, std::string>::const_iterator it(options.find(name));
-if (it == options.end())
-    return;
-conv(it->second, res);
+    std::map<std::string, std::string>::const_iterator it(options.find(name));
+    if (it == options.end())
+        return;
+    conv(it->second, res);
 }
 
 template <>
 inline
-void MaybeSet<std::string>(const std::map<std::string, std::string> & options, const std::string & name, STG::Optional<std::string> & res)
+void MaybeSet<std::string>(const std::map<std::string, std::string> & options, const std::string & name, std::optional<std::string> & res)
 {
-std::map<std::string, std::string>::const_iterator it(options.find(name));
-if (it == options.end())
-    return;
-res = it->second;
+    std::map<std::string, std::string>::const_iterator it(options.find(name));
+    if (it == options.end())
+        return;
+    res = it->second;
 }
 
 } // namespace SGCONF