2014-06-01 17:55:23 +00:00
|
|
|
/*
|
2018-09-02 00:57:29 +00:00
|
|
|
* This file is part of the DXX-Rebirth project <https://www.dxx-rebirth.com/>.
|
2014-06-01 17:55:23 +00:00
|
|
|
* It is copyright by its individual contributors, as recorded in the
|
|
|
|
* project's Git history. See COPYING.txt at the top level for license
|
|
|
|
* terms and a link to the Git history.
|
|
|
|
*/
|
2013-12-04 22:38:04 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <cstddef>
|
|
|
|
#include "dxxsconf.h"
|
2020-05-02 21:18:42 +00:00
|
|
|
#include <array>
|
2013-12-04 22:38:04 +00:00
|
|
|
|
|
|
|
template <std::size_t N>
|
2022-09-24 17:47:53 +00:00
|
|
|
class cstring_tie : std::array<const char *, N>
|
2013-12-04 22:38:04 +00:00
|
|
|
{
|
|
|
|
public:
|
2014-07-14 02:12:39 +00:00
|
|
|
static const std::size_t maximum_arity = N;
|
2020-05-02 21:18:42 +00:00
|
|
|
using array_t = std::array<const char *, maximum_arity>;
|
2013-12-04 22:38:04 +00:00
|
|
|
template <typename... Args>
|
2022-09-24 17:47:53 +00:00
|
|
|
requires(sizeof...(Args) <= maximum_arity)
|
|
|
|
cstring_tie(Args&&... args) :
|
|
|
|
array_t{{args...}}, m_count(sizeof...(Args))
|
2013-12-04 22:38:04 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
unsigned count() const { return m_count; }
|
2022-09-24 17:47:53 +00:00
|
|
|
const char *string(std::size_t i) const { return this->operator[](i); }
|
|
|
|
using array_t::begin;
|
2022-10-09 23:15:20 +00:00
|
|
|
auto end() const
|
|
|
|
{
|
|
|
|
return std::next(begin(), m_count);
|
|
|
|
}
|
2013-12-04 22:38:04 +00:00
|
|
|
private:
|
|
|
|
unsigned m_count;
|
|
|
|
};
|