Frage

HALLO Könnte jemand ein Beispielprogramm gibt den is_same_type Typen Merkmal in C ++?

implementieren
War es hilfreich?

Lösung

#include <iostream>

template< typename T1, typename T2 >
struct is_same_type      { enum { result = false }; };

template< typename T>
struct is_same_type<T,T> { enum { result = true }; };


int main()
{
    std::cout << is_same_type<int,float>::result << '\n'
              << is_same_type<char,char>::result << '\n';
    return 0;
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top