Browse code

Replace std::not1 with a lamba.

Naram Qashat authored on 2021/03/20 17:45:09
Showing 1 changed files
... ...
@@ -24,24 +24,26 @@ static inline void Set32BitsLE(uint32_t input, uint8_t *output)
24 24
 // The whitespace trimming was modified from the following answer on Stack Overflow:
25 25
 // http://stackoverflow.com/a/217605
26 26
 
27
-struct IsWhitespace
27
+bool IsWhitespace(const char &x)
28 28
 {
29
-  using argument_type = char;;
30
-	bool operator()(const char &x) const
31
-	{
32
-		return x >= 0x01 && x <= 0x20;
33
-	}
34
-};
29
+	return x >= 0x01 && x <= 0x20;
30
+}
35 31
 
36 32
 static inline std::string LeftTrimWhitespace(const std::string &orig)
37 33
 {
38
-	auto first_non_space = std::find_if(orig.begin(), orig.end(), std::not1(IsWhitespace()));
34
+	auto first_non_space = std::find_if(orig.begin(), orig.end(), [](const char &x)
35
+	{
36
+		return !IsWhitespace(x);
37
+	});
39 38
 	return std::string(first_non_space, orig.end());
40 39
 }
41 40
 
42 41
 static inline std::string RightTrimWhitespace(const std::string &orig)
43 42
 {
44
-	auto last_non_space = std::find_if(orig.rbegin(), orig.rend(), std::not1(IsWhitespace())).base();
43
+	auto last_non_space = std::find_if(orig.rbegin(), orig.rend(), [](const char &x)
44
+	{
45
+		return !IsWhitespace(x);
46
+	}).base();
45 47
 	return std::string(orig.begin(), last_non_space);
46 48
 }
47 49