mirror of
https://github.com/sendyne/cppreg.git
synced 2025-05-09 23:24:05 +00:00
FIX FOR LOOP IMPLEMENTATION AND ADD RANGE LOOP
* Fixes a typo in the for_loop implementation. * Add a range_loop implementation to help with indexed register pack.
This commit is contained in:
parent
49d19f1b20
commit
ee48bbd261
@ -160,8 +160,9 @@ namespace cppreg {
|
|||||||
*/
|
*/
|
||||||
template <typename... T>
|
template <typename... T>
|
||||||
struct PackIndexing {
|
struct PackIndexing {
|
||||||
|
using tuple_t = typename std::tuple<T...>;
|
||||||
template <std::size_t N>
|
template <std::size_t N>
|
||||||
using regs = typename std::tuple_element<N, std::tuple<T...>>::type;
|
using regs = typename std::tuple_element<N, tuple_t>::type;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -179,17 +180,17 @@ namespace cppreg {
|
|||||||
*
|
*
|
||||||
* This will call Op for the range [start, end).
|
* This will call Op for the range [start, end).
|
||||||
*/
|
*/
|
||||||
template <template <std::size_t> class Op, typename T = void>
|
template <typename Op, typename T = void>
|
||||||
inline static void loop(
|
inline static void loop(
|
||||||
typename std::enable_if<start < end, T>::type* = nullptr
|
typename std::enable_if<start < end, T>::type* = nullptr
|
||||||
) {
|
) {
|
||||||
Op<start>()();
|
Op().template operator()<start>();
|
||||||
if (start < end)
|
if (start < end)
|
||||||
for_loop<start + 1, end>::template iterate<Op>();
|
for_loop<start + 1, end>::template loop<Op>();
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Loop method closure.
|
//! Loop method closure.
|
||||||
template <template <std::size_t> class Op, typename T = void>
|
template <typename Op, typename T = void>
|
||||||
inline static void loop(
|
inline static void loop(
|
||||||
typename std::enable_if<start >= end, T>::type* = nullptr
|
typename std::enable_if<start >= end, T>::type* = nullptr
|
||||||
) {};
|
) {};
|
||||||
@ -197,6 +198,16 @@ namespace cppreg {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//! Template range loop implementation.
|
||||||
|
/**
|
||||||
|
* @tparam IndexedPack Indexed pack type.
|
||||||
|
*/
|
||||||
|
template <typename IndexedPack>
|
||||||
|
struct range_loop : for_loop<
|
||||||
|
0, std::tuple_size<typename IndexedPack::tuple_t>::value
|
||||||
|
> {};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user