cnorxz/src/include/xfor/for_utils.h

40 lines
866 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"
#include <array>
#include <tuple>
namespace MultiArrayHelper
{
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
}
};
} // end namespace MultiArrayHelper
#endif