ezconfig
Create C++ Objects from Yaml and Json
Loading...
Searching...
No Matches
meta.hpp
1#pragma once
2
3#include <cstddef>
4#include <type_traits>
5
6namespace ezconfig {
7
8template<typename _Tp, typename... _Types>
9constexpr std::size_t index_in_typepack()
10{
11 constexpr std::size_t tpsize = sizeof...(_Types);
12 constexpr bool found[tpsize] = {std::is_same_v<_Tp, _Types>...};
13 std::size_t n = tpsize;
14 for (std::size_t i = 0; i < tpsize; ++i) {
15 if (found[i]) {
16 if (n < tpsize) { return tpsize; } // more than one _Tp found
17 n = i;
18 }
19 }
20 return n;
21}
22
23} // namespace ezconfig