Template declarations (class, function, and variables (since C++14)) can appear inside a member specification of any class, struct, or union that aren't local classes.
#include <iostream>
#include <vector>
#include <algorithm>
struct Printer { // generic functor
std::ostream& os;
Printer(std::ostream& os) : os(os) {}
template<typename T>
void operator()(const T& obj) { os << obj << ' '; } // member template
};
int main()
{