30 template<
typename... Ts>
34 template<
typename T,
typename... Ts>
36 :
public std::integral_constant<bool,
37 (std::is_integral<T>::value && are_integral<Ts...>::value)>
41 template<
typename... Ts>
54 template<std::size_t I = 0,
57 std::enable_if_t<std::tuple_size<TupleA>::value ==
58 std::tuple_size<TupleB>::value &&
59 I == std::tuple_size<TupleA>::value - 1> * =
nullptr>
62 return (std::get<I>(a) < std::get<I>(b));
66 template<std::size_t I = 0,
69 typename = std::enable_if_t<std::tuple_size<TupleA>::value ==
70 std::tuple_size<TupleB>::value &&
71 (I < std::tuple_size<TupleA>::value - 1) &&
72 std::tuple_size<TupleA>::value >= 2>>
74 less_than(
const TupleA & a,
const TupleB & b) {
75 if(std::get<I>(a) == std::get<I>(b))
76 return less_than<I + 1>(a, b);
78 return (std::get<I>(a) < std::get<I>(b));
90 template<std::size_t I = 0,
93 std::enable_if_t<std::tuple_size<TupleA>::value ==
94 std::tuple_size<TupleB>::value &&
95 I == std::tuple_size<TupleA>::value - 1> * =
nullptr>
98 return (std::get<I>(a) == std::get<I>(b));
102 template<std::size_t I = 0,
105 typename = std::enable_if_t<std::tuple_size<TupleA>::value ==
106 std::tuple_size<TupleB>::value &&
107 (I < std::tuple_size<TupleA>::value - 1) &&
108 std::tuple_size<TupleA>::value >= 2>>
110 equal_to(
const TupleA & a,
const TupleB & b) {
111 if(std::get<I>(a) != std::get<I>(b))
114 return equal_to<I + 1>(a, b);
126 template<std::size_t I = 0,
128 std::enable_if_t<I == std::tuple_size<TupleA>::value - 1> * =
nullptr>
130 print(std::ostream & output,
const TupleA & a,
const char *) {
131 output << std::get<I>(a);
136 template<std::size_t I = 0,
138 typename = std::enable_if_t<(I < std::tuple_size<TupleA>::value - 1) &&
139 std::tuple_size<TupleA>::value >= 2>>
141 print(std::ostream & output,
const TupleA & a,
const char * sep) {
142 output << std::get<I>(a) << sep;
143 return print<I + 1>(output, a, sep);
159 template<
typename... Args>
161 using value_type =
typename std::tuple<Args...>;
162 bool operator()(
const value_type & a,
const value_type & b)
const {
163 return detail::less_than(a, b);
177 template<
typename T,
typename Compare>
181 template<
template<
typename>
class Compare,
typename... Args>
182 class simple_id_t<std::tuple<Args...>, Compare<std::tuple<Args...>>>
190 using value_type = std::tuple<Args...>;
196 static constexpr
auto length_ =
sizeof...(Args);
217 template<
typename... Ts,
218 typename = std::enable_if_t<
sizeof...(Ts) ==
sizeof...(Args)>>
219 simple_id_t(Ts &&... ts) : data_{std::make_tuple(std::forward<Ts>(ts)...)} {}
222 static constexpr
auto size() noexcept {
232 detail::print(output,
id.data_,
", ");
240 return detail::equal_to(data_,
id.data_);
247 return Compare<value_type>{}(data_,
id.data_);
friend std::ostream & operator<<(std::ostream &output, const simple_id_t &id)
Definition: simple_id.hh:230
std::ostream & print(std::ostream &output, const TupleA &a, const char *)
Print function for a tuple.
Definition: simple_id.hh:130
simple_id_t(const value_type &data)
Definition: simple_id.hh:211
simple_id_t(Ts &&... ts)
Definition: simple_id.hh:219
bool operator<(const simple_id_t &id) const
Definition: simple_id.hh:246
A simple id type that can be constructed from multiple indexes.
Definition: simple_id.hh:178
A helper to identify if all types Ts are integral.
Definition: simple_id.hh:31
static constexpr auto size() noexcept
Return the size of the tuple.
Definition: simple_id.hh:222
bool operator==(const simple_id_t &id) const
Definition: simple_id.hh:239
constexpr bool are_integral_v
Equal to true if Ts are all integral types.
Definition: simple_id.hh:42
bool less_than(const TupleA &a, const TupleB &b)
Comparison function for two tuples Comparison is done in a lexical fashion.
Definition: simple_id.hh:61
Definition: simple_id.hh:155
bool equal_to(const TupleA &a, const TupleB &b)
Comparison function for two tuples.
Definition: simple_id.hh:97
Definition: control.hh:31