-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathrename.hpp
45 lines (35 loc) · 889 Bytes
/
rename.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include "ra/operation.hpp"
#include "sql/row.hpp"
namespace ra
{
template <typename Output, typename Input>
class rename : public ra::unary<Input>
{
using input_type = typename ra::unary<Input>::input_type;
public:
using output_type = Output;
static auto&& next()
{
fold<output_type, input_type>(output_row, Input::next());
return std::move(output_row);
}
private:
template <typename Dest, typename Src>
static inline constexpr void fold(Dest& dest, Src const& src)
{
if constexpr (Dest::depth == 0)
{
return;
}
else
{
dest.head() = src.head();
fold<typename Dest::next, typename Src::next>(dest.tail(), src.tail());
}
}
static output_type output_row;
};
template <typename Output, typename Input>
typename rename<Output, Input>::output_type rename<Output, Input>::output_row{};
} // namespace ra