From d65ebaeef2379702500143dd09290e17b2d58752 Mon Sep 17 00:00:00 2001
From: Bensong Liu <bensl@microsoft.com>
Date: Tue, 28 Jul 2020 13:38:57 +0800
Subject: [PATCH] fix msvc compilation issue on opt_parser::getValueArg
 overloading

---
 Makefile |  2 +-
 opt.hpp  | 35 +++++++++++++++++++++--------------
 2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/Makefile b/Makefile
index 1587264..e7e2e1d 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ ARFLAGS = rcs
 PREFIX ?= /usr
 
 def:
-	@echo Run make install
+	@echo This library is header-only, and no need to compile. Run make install if you would like. 
 
 install_header:
 	[ ! -d $(PREFIX)/include/rlib ] || rm -rf $(PREFIX)/include/rlib
diff --git a/opt.hpp b/opt.hpp
index 3654fdf..905ae26 100644
--- a/opt.hpp
+++ b/opt.hpp
@@ -79,20 +79,8 @@ namespace rlib {
             }
         }
 
-        rlib::string getValueArg(const std::string &longName, const char *shortName)
-        { //getValueArg("--long", "-l") may be converted to getValueArg("--long", true).
-            return getValueArg(longName, shortName, true);
-        }
-
-        bool getBoolArg(const std::string &argName)
-        { //Return if it's defined.
-            auto pos = std::find(args.cbegin(), args.cend(), argName);
-            if(pos == args.cend()) return false;
-            args.erase(pos);
-            return true;
-        }
-
-        rlib::string getValueArg(const std::string &longName, const std::string &shortName, bool required = true, const std::string &def = std::string())
+        // rlib::string getValueArg(const std::string &longName, const std::string &shortName, bool required = true, const std::string &def = std::string()) // MSVC doesn't allow this overload.
+        rlib::string getValueArg(const std::string &longName, const std::string &shortName, bool required, const std::string &def)
         {
             using rlib::literals::operator "" _format;
             std::string valueL = getValueArg(longName, false);
@@ -107,6 +95,25 @@ namespace rlib {
             }
             return std::move(value);
         }
+        rlib::string getValueArg(const std::string &longName, const std::string &shortName, bool required) {
+            return getValueArg(longName, shortName, required, std::string());
+        }
+        rlib::string getValueArg(const std::string &longName, const std::string &shortName) {
+            return getValueArg(longName, shortName, true, std::string());
+        }
+
+        rlib::string getValueArg(const std::string &longName, const char *shortName)
+        { //getValueArg("--long", "-l") may be converted to getValueArg("--long", true).
+            return getValueArg(longName, shortName, true);
+        }
+
+        bool getBoolArg(const std::string &argName)
+        { //Return if it's defined.
+            auto pos = std::find(args.cbegin(), args.cend(), argName);
+            if(pos == args.cend()) return false;
+            args.erase(pos);
+            return true;
+        }
 
         bool getBoolArg(const std::string &longName, const std::string &shortName)
         {
-- 
GitLab