summaryrefslogtreecommitdiff
path: root/louloulibs/utils/get_first_non_empty.hpp
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2016-12-21 21:25:09 +0100
committerJonas Smedegaard <dr@jones.dk>2016-12-21 21:25:09 +0100
commitf820d86aadb7a5473bcc0a0a3669732ab0182555 (patch)
treea6a673c444ea3df75fe0a5d53e905030c2f617ce /louloulibs/utils/get_first_non_empty.hpp
parenteda4b75b1cff83336e87da90efca9fd6b4ced2c7 (diff)
parent9634cdaba2e5d2343fcbc1f07264d55609640273 (diff)
downloadbiboumi-f820d86aadb7a5473bcc0a0a3669732ab0182555.tar.gz
biboumi-f820d86aadb7a5473bcc0a0a3669732ab0182555.tar.bz2
biboumi-f820d86aadb7a5473bcc0a0a3669732ab0182555.tar.xz
biboumi-f820d86aadb7a5473bcc0a0a3669732ab0182555.zip
New upstream version 4.0upstream/4.0
Diffstat (limited to 'louloulibs/utils/get_first_non_empty.hpp')
-rw-r--r--louloulibs/utils/get_first_non_empty.hpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/louloulibs/utils/get_first_non_empty.hpp b/louloulibs/utils/get_first_non_empty.hpp
new file mode 100644
index 0000000..a38f5fb
--- /dev/null
+++ b/louloulibs/utils/get_first_non_empty.hpp
@@ -0,0 +1,20 @@
+#pragma once
+
+#include <string>
+
+bool is_empty(const std::string& val);
+bool is_empty(const int& val);
+
+template <typename T>
+T get_first_non_empty(T&& last)
+{
+ return last;
+}
+
+template <typename T, typename... Args>
+T get_first_non_empty(T&& first, Args&&... args)
+{
+ if (!is_empty(first))
+ return first;
+ return get_first_non_empty(std::forward<Args>(args)...);
+}