문제

you can typedef a data type:

typedef String std::string;

You can typedef a function

typedef String itos(int val);
itos std::to_string;

How can you typedef an overloaded function

eg.

typedef String to_string(all overloads);
to_string std::to_string;
도움이 되었습니까?

해결책

In C++ overload mechanism allows to call functions with the same name but different argument types. Each overloaded function has different type (really they all are separate functions). For each such function compiler generates decorated names of the functions, adding parameter types to the function name, so that linker can distinguish them.

typedef does not create separate type. So, you cannot match several types to one typedef declaration, it is impossible. In C++11 you can use using type aliasing instead of typedef which has more clear syntax.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top