tlx
index_sequence.hpp
Go to the documentation of this file.
1/*******************************************************************************
2 * tlx/meta/index_sequence.hpp
3 *
4 * Part of tlx - http://panthema.net/tlx
5 *
6 * Copyright (C) 2016-2017 Timo Bingmann <tb@panthema.net>
7 *
8 * All rights reserved. Published under the Boost Software License, Version 1.0
9 ******************************************************************************/
10
11#ifndef TLX_META_INDEX_SEQUENCE_HEADER
12#define TLX_META_INDEX_SEQUENCE_HEADER
13
14#include <cstddef>
15
16namespace tlx {
17
18//! \addtogroup tlx_meta
19//! \{
20
21// Compile-time integer sequences, an implementation of std::index_sequence and
22// std::make_index_sequence, as these are not available in many current
23// libraries (MS Visual C++).
24template <size_t... Indexes>
26 static size_t size() { return sizeof ... (Indexes); }
27};
28
29namespace meta_detail {
30
31template <size_t CurrentIndex, size_t... Indexes>
32struct make_index_sequence_helper;
33
34template <size_t... Indexes>
35struct make_index_sequence_helper<0, Indexes...> {
36 using type = index_sequence<Indexes...>;
37};
38
39template <size_t CurrentIndex, size_t... Indexes>
42 CurrentIndex - 1, CurrentIndex - 1, Indexes...>::type;
43};
44
45} // namespace meta_detail
46
47template <size_t Size>
49 : public meta_detail::make_index_sequence_helper<Size>::type { };
50
51//! \}
52
53} // namespace tlx
54
55#endif // !TLX_META_INDEX_SEQUENCE_HEADER
56
57/******************************************************************************/
static size_t size()
typename make_index_sequence_helper< CurrentIndex - 1, CurrentIndex - 1, Indexes... >::type type