#include <range/v3/all.hpp>
using namespace ranges;
template<typename I, typename O>
tagged_pair<tag::in(I), tag::out(O)>
f(I i, O o)
{
return { i, o };
}
int main()
{
char buf[8]{};
f(std::begin(buf), std::end(buf));
}
The code uses range-v3 and can be compiled with clang
.
However, I cannot understand why the line tagged_pair<tag::in(I), tag::out(O)>
is legal. I
is a type, tag::in(I)
is also a type, and tag::in
is not a macro, how does tag::in(I)
give a type at compile-time?
See also http://en.cppreference.com/w/cpp/experimental/ranges/algorithm/copy
It is a type of a function accepting I
and returning tag::in
, which is also a type.
This is used, for example in std::function
, like std::function<void(int)>
.