Add get_first_non_empty and use it into Database to simplify a little bit

This commit is contained in:
louiz’
2016-08-21 01:51:52 +02:00
parent c97e349821
commit 992fa93895
5 changed files with 49 additions and 6 deletions
+20
View File
@@ -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)...);
}