Программы на C++. Форум разработчиков
Anonymous
Что означает шаблон ?
Сообщение
Anonymous » 01 окт 2025, 13:40
Я читал этот пример доисторического метапрогама, чтобы определить, поддерживает ли класс участник. (или любой другой член). < /p>
Код: Выделить всё
template
class DetectFind
{
struct Fallback { int find; };
struct Derived : T, Fallback { };
template struct Check;
typedef char Yes[1];
typedef char No[2];
template
static No& func(Check*);
template
static Yes& func(...);
public:
typedef DetectFind type;
enum { value = sizeof(func(0)) == sizeof(Yes) };
};
int main()
{
std::cout
Подробнее здесь: [url]https://stackoverflow.com/questions/68996404/what-does-templatetypename-t-t-mean[/url]
1759315208
Anonymous
Я читал этот пример доисторического метапрогама, чтобы определить, поддерживает ли класс участник. (или любой другой член). < /p> [code]template class DetectFind { struct Fallback { int find; }; struct Derived : T, Fallback { }; template struct Check; typedef char Yes[1]; typedef char No[2]; template static No& func(Check*); template static Yes& func(...); public: typedef DetectFind type; enum { value = sizeof(func(0)) == sizeof(Yes) }; }; int main() { std::cout Подробнее здесь: [url]https://stackoverflow.com/questions/68996404/what-does-templatetypename-t-t-mean[/url]