~singpolyma/biboumi

ref: f0f3d3d4e2fb7c02a5b2ad517632ec5071fefb45 biboumi/src/utils/get_first_non_empty.hpp -rw-r--r-- 372 bytes
f0f3d3d4 — louiz’ Remove the now useless “find … touch” hack in gitlab-ci.yml 5 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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)...);
}