How does a function call give a compile-time type?

#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 figure out why the string tagged_pair<tag::in(I), tag::out(O)>

is legal. I

is a type, is tag::in(I)

also a type, tag::in

not a macro, how tag::in(I)

does a type give at compile time?

See also http://en.cppreference.com/w/cpp/experimental/ranges/algorithm/copy

+3


source to share


1 answer


It is the type of a function that takes I

and returns tag::in

, which is also a type.



This is used, for example, in std::function

eg std::function<void(int)>

.

+10


source







All Articles