What is the operator << <> in C ++?

I saw this in several places, and to confirm that I was not crazy, I looked for other examples . Apparently, it can be in other tastes, for example operator+ <>.

However, none of what I saw mentions what it is, so I thought I'd ask.

It's not the easiest thing to google operator<< <>(: -)

+3
source share
1 answer

<>after the function name (including the operator, for example operator<<) in the declaration indicates that it is a specialized function. For example, with a regular function template:

template <typename T>
void f(T x) { }

template<>
void f<>(int x) { } // specialization for T = int

( , , , )

<> , , :

template <typename T> 
void g(T x) { }   // (1)

void g(int x) { } // (2)

g(42);   // calls (2)
g<>(42); // calls (1)

, operator<< <> .

+13

Source: https://habr.com/ru/post/1749314/


All Articles