Suppose I have a bunch of vectors:
vector v1;
vector v2;
vector v3;
all of the same length. Now, for ev
Conversion to a std::tuple of vectors (vector::iterators):
#include
#include
// identity
// ========
struct identity
{
template
struct apply {
typedef T type;
};
};
// concat_operation
// ================
template struct concat_operation;
template <
typename Operator,
typename ...Types,
typename T>
struct concat_operation, T>
{
private:
typedef typename Operator::template apply::type concat_type;
public:
typedef std::tuple type;
};
template <
typename Operator,
typename ...Types,
typename T,
typename ...U>
struct concat_operation, T, U...>
{
private:
typedef typename Operator::template apply::type concat_type;
public:
typedef typename concat_operation<
Operator,
std::tuple,
U...>
::type type;
};
template <
typename Operator,
typename T,
typename ...U>
struct concat_operation
{
private:
typedef typename Operator::template apply::type concat_type;
public:
typedef typename concat_operation<
Operator,
std::tuple,
U...>
::type type;
};
// ToVectors (ToVBackedVoT)
// =========
template
struct ToVectors
{
private:
struct to_vector {
template
struct apply {
typedef typename std::vector type;
};
};
public:
typedef typename concat_operation::type type;
};
// ToIterators
// ===========
template
struct ToIterators;
template
struct ToIterators>
{
private:
struct to_iterator {
template
struct apply {
typedef typename V::iterator type;
};
};
public:
typedef typename concat_operation::type type;
};
int main() {
typedef ToVectors::type Vectors;
typedef ToVectors::type MoreVectors;
typedef ToIterators::type Iterators;
// LOG_TYPE(Vectors);
// std::tuple<
// std::vector >,
// std::vector >,
// std::vector > >
// LOG_TYPE(Iterators);
// std::tuple<
// __gnu_cxx::__normal_iterator > >,
// __gnu_cxx::__normal_iterator > >,
// __gnu_cxx::__normal_iterator > > >
}