What will be printed out as a result of the following code execution?
template<class T, class U>
struct A{
	struct dummy{char _[2];};
	static char _(T);
	static dummy _(...);
	static const bool value=sizeof(_(U()))==sizeof(char);
};
struct B{};
struct C:B{};
...
cout << A<B,C>::value << A<B,B>::value << A<C,B>::value;
Explanation
If the class U is cast to type T (that is, it is the same class, it is as an inheritor, it provides a cast operator to type T or there is another trivial way to cast to T), the function _(T) will be called, otherwise _(...) will be called which accepts any number of parameters of any type.
After that, sizeof determines the size of the object returned by the called function.

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты