diff options
author | Jonas Smedegaard <dr@jones.dk> | 2016-12-21 21:25:17 +0100 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2016-12-21 21:25:17 +0100 |
commit | dc1ad45aea9a10007a31ae449b1e0fe352a8a6cd (patch) | |
tree | eb233ce97fc828e2edba69a82a1e7314b92771d3 /louloulibs/utils/get_first_non_empty.hpp | |
parent | a077b304b27d21bf635ef4f31a2a0447d3b14d11 (diff) | |
parent | f820d86aadb7a5473bcc0a0a3669732ab0182555 (diff) | |
download | biboumi-dc1ad45aea9a10007a31ae449b1e0fe352a8a6cd.tar.gz biboumi-dc1ad45aea9a10007a31ae449b1e0fe352a8a6cd.tar.bz2 biboumi-dc1ad45aea9a10007a31ae449b1e0fe352a8a6cd.tar.xz biboumi-dc1ad45aea9a10007a31ae449b1e0fe352a8a6cd.zip |
Merge tag 'upstream/4.0'
Upstream version 4.0
# gpg: Signature made Wed Dec 21 21:25:11 2016 CET
# gpg: using RSA key 2C7C3146C1A00121
# gpg: Good signature from "Jonas Smedegaard <dr@jones.dk>"
# gpg: aka "Jonas Smedegaard <jonas@homebase.dk>"
# gpg: aka "Jonas Smedegaard <js@debian.org>"
# gpg: aka "[jpeg image of size 4165]"
Diffstat (limited to 'louloulibs/utils/get_first_non_empty.hpp')
-rw-r--r-- | louloulibs/utils/get_first_non_empty.hpp | 20 |
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)...); +} |