cnorxz/src/include/xfor/for_utils.h

40 lines
864 B
C
Raw Normal View History

2018-01-09 11:37:26 +01:00
#ifndef __for_utils_h__
#define __for_utils_h__
//#include "ranges/rheader.h"
2018-01-09 11:37:26 +01:00
#include <array>
#include <tuple>
2021-07-28 20:29:56 +02:00
namespace CNORXZInternal
2018-01-09 11:37:26 +01:00
{
namespace {
template <class Op>
using to_size_t = size_t;
}
template <size_t N>
struct XFPackNum
{
template <class ETuple, typename... Args>
2018-01-18 23:14:49 +01:00
static inline ETuple mkPos(size_t pos, const ETuple& et, const ETuple& lt, const Args&... args)
2018-01-09 11:37:26 +01:00
{
return std::move( XFPackNum<N-1>::mkPos(pos, et, lt, std::get<N>(lt) + pos * std::get<N>(et), args...) );
2018-01-09 11:37:26 +01:00
}
};
template <>
struct XFPackNum<0>
{
template <class ETuple, typename... Args>
2018-01-18 23:14:49 +01:00
static inline ETuple mkPos(size_t pos, const ETuple& et, const ETuple& lt, const Args&... args)
2018-01-09 11:37:26 +01:00
{
return ETuple(std::get<0>(lt) + pos * std::get<0>(et), args...);
2018-01-09 11:37:26 +01:00
}
};
2021-07-28 20:29:56 +02:00
} // end namespace CNORXZInternal
2018-01-09 11:37:26 +01:00
#endif