Debian Codegraph @

common/include/varutil.h

raw
1 /*
2 * This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
3 * It is copyright by its individual contributors, as recorded in the
4 * project's Git history. See COPYING.txt at the top level for license
5 * terms and a link to the Git history.
6 */
7 #pragma once
8
9 #include <cstddef>
10 #include "dxxsconf.h"
11 #include <array>
12
13 template <std::size_t N>
14 class cstring_tie : std::array<const char *, N>
15 {
16 public:
17 static const std::size_t maximum_arity = N;
18 using array_t = std::array<const char *, maximum_arity>;
19 template <typename... Args>
20 requires(sizeof...(Args) <= maximum_arity)
21 cstring_tie(Args&&... args) :
22 array_t{{args...}}, m_count{sizeof...(Args)}
23 {
24 }
25 unsigned count() const { return m_count; }
26 const char *string(std::size_t i) const { return this->operator[](i); }
27 using array_t::begin;
28 auto end() const
29 {
30 return std::next(begin(), m_count);
31 }
32 private:
33 unsigned m_count;
34 };