-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathenum_sequence.hpp
More file actions
72 lines (72 loc) · 1.41 KB
/
enum_sequence.hpp
File metadata and controls
72 lines (72 loc) · 1.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#ifndef ENUM_SEQUENCE_HPP_INCLUDED
#define ENUM_SEQUENCE_HPP_INCLUDED
//Purpose:
// create enum_sequence that's like
// std::integer_sequence except for enumerations.
#include <utility>//std::integer_sequence
#include <type_traits>//std::underlying_type
template
< typename Enumeration
, Enumeration... Enumerators
>
struct
enum_sequence
{};
namespace detail_enum_sequence
{ //helper struct's for use by make_enum_sequence.
template
< typename Enumeration
, typename Indices
>
struct
cast_enum_seq
;
template
< typename Enumeration
, typename EnumUnderly
, EnumUnderly... Indices
>
struct
cast_enum_seq
< Enumeration
, std::integer_sequence
< EnumUnderly
, Indices...
>
>
{
using
type
= enum_sequence<Enumeration, Enumeration(Indices)...>
;
};
template
< typename Enumeration
, typename EnumUnderly
, Enumeration Last
>
struct
cast_enum
: cast_enum_seq
< Enumeration
, std::make_integer_sequence
< EnumUnderly
, EnumUnderly(Last)
>
>
{
};
}//exit detail_enum_sequence namespace
template
< typename Enumeration
, Enumeration Last
>
using
make_enum_sequence=typename
detail_enum_sequence::cast_enum
< Enumeration
, std::underlying_type_t<Enumeration>
, Last
>::type
;
#endif//ENUM_SEQUENCE_HPP_INCLUDED