Subversion Repositories Games.Descent

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1 pmbaty 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 <algorithm>
11
#include "dxxsconf.h"
12
#include <array>
13
 
14
template <std::size_t N>
15
class cstring_tie
16
{
17
public:
18
        static const std::size_t maximum_arity = N;
19
        using array_t = std::array<const char *, maximum_arity>;
20
        template <typename... Args>
21
                cstring_tie(Args&&... args) : p(array_t{{args...}}), m_count(sizeof...(Args))
22
        {
23
                static_assert(sizeof...(Args) <= maximum_arity, "too many arguments to cstring_tie");
24
        }
25
        unsigned count() const { return m_count; }
26
        const char *string(std::size_t i) const { return p[i]; }
27
private:
28
        array_t p;
29
        unsigned m_count;
30
};