1 #ifndef SIPLASPLAS_CONSTEXPR_META_HPP 2 #define SIPLASPLAS_CONSTEXPR_META_HPP 4 #include "arrayview.hpp" 6 #include <siplasplas/utility/meta.hpp> 17 template<
typename Seq,
typename TypeToValue>
20 template<
template<
typename...>
class Seq,
typename Head,
typename... Tail,
typename TypeToValue>
24 using value_type =
typename TypeToValue::value_type;
28 static constexpr
const value_type&
get(std::size_t i)
40 static constexpr std::size_t size()
42 return sizeof...(Tail) + 1;
45 static constexpr
const value_type*
begin()
50 static constexpr
const value_type*
end()
52 return array + size();
55 static constexpr
const value_type*
const cbegin()
60 static constexpr
const value_type*
const cend()
62 return array + size();
66 constexpr std::size_t size()
const 68 return Bounds::size();
71 constexpr
const value_type& operator[](std::size_t i)
const 76 constexpr
const value_type*
begin()
const 81 constexpr
const value_type*
end()
const 86 constexpr
const value_type*
const cbegin()
const 88 return Bounds::cbegin();
91 constexpr
const value_type*
const cend()
const 93 return Bounds::cend();
97 static constexpr value_type array[] = {
98 TypeToValue::template get<Head>(),
99 TypeToValue::template get<Tail>()...
103 template<
template<
typename...>
class Seq,
typename Head,
typename... Tail,
typename TypeToValue>
104 constexpr
typename TypeToValue::value_type
SequenceToArray<Seq<Head, Tail...>, TypeToValue>::array[
sizeof...(Tail) + 1];
106 template<
template<
typename...>
class Seq,
typename TypeToValue>
110 using value_type =
typename TypeToValue::value_type;
114 static constexpr
const value_type&
get(std::size_t i)
116 return *
static_cast<value_type*
>(
nullptr);
121 static constexpr std::size_t size()
126 static constexpr
const value_type*
begin()
131 static constexpr
const value_type*
end()
136 static constexpr
const value_type*
const cbegin()
141 static constexpr
const value_type*
const cend()
149 return {
static_cast<value_type*
>(
nullptr), static_cast<std::size_t>(0)};
152 constexpr std::size_t size()
const 154 return Bounds::size();
157 constexpr
const value_type& operator[](std::size_t i)
const 162 constexpr
const value_type*
begin()
const 167 constexpr
const value_type*
end()
const 172 constexpr
const value_type*
const cbegin()
const 174 return Bounds::cbegin();
177 constexpr
const value_type*
const cend()
const 179 return Bounds::cend();
186 using value_type = T;
188 template<
typename IntegralConstant>
189 static constexpr value_type
get()
191 return IntegralConstant::value;
195 template<
typename T, T... Values>
201 template<
typename String>
204 template<
template<
typename...>
class Seq,
char... Chars>
208 static constexpr
const String<
sizeof...(Chars) + 1>& str()
213 static constexpr
const char* c_str()
219 static constexpr
String<
sizeof...(Chars) + 1> _str{
224 template<
template<
typename...>
class Seq,
char... Chars>
225 constexpr
String<
sizeof...(Chars) + 1>
SequenceToString<Seq<std::integral_constant<char, Chars>...>>::_str;
227 template<
typename Lhs,
typename LhsToValue,
typename Rhs,
typename RhsToValue>
233 template<
typename Lhs,
typename LhsToValue,
typename Rhs,
typename RhsToValue>
236 return !(lhs == rhs);
239 template<
typename Sequence,
typename ToValue>
240 std::ostream& operator<<(std::ostream& os, const SequenceToArray<Sequence, ToValue>& sequence)
244 for(std::size_t i = 0; i < sequence.size(); ++i)
246 if(i < sequence.size() - 1)
248 os << sequence[i] <<
", ";
259 template<
char... Chars>
268 #endif // SIPLASPLAS_CONSTEXPR_META_HPP Definition: arrayview.hpp:87
Definition: messaging.hpp:8
constexpr bool equal(Begin1 begin1, End1 end1, Begin2 begin2, End2 end2, Compare compare)
Compares if two sequences are equal.
Definition: algorithm.hpp:137
Definition: variant.hpp:500
Definition: string.hpp:17
constexpr auto end(const Sequence &sequence)
Returns an iterator pointing to the end of a sequence.
Definition: algorithm.hpp:86
constexpr auto begin(const Sequence &sequence)
Returns an iterator pointing to the beginning of a sequence.
Definition: algorithm.hpp:62