[정리]int2type


[정리]int2type

핵심개념 1. 함수 오버로딩은 인자 개수가 다르거나 인자의 타입이 다를 때 사용한다. 2. 인자의 개수와 타입이 동일할 때 인자의 값 만으로는 오버로딩을 할 수 없다. int main() { foo(3); foo(3.4); // 아래 두 함수가 다른 함수를 호출하게 할 수 없을까? foo(0); foo(1); } "int2type<>은 정수형 상수를 독립된 타입으로 만드는 도구" 즉, 77, 78은 모두 같은 타입(int)이지만 int2type<77>, int2type<78>은 각각 독립된 별개의 타입이 된다. int를 type으로 만든다는 의미로 이름이 int2type 이다. #include <iostream> using namespace std; template<int N> struct int2type { enum {value = N}; }; void foo(int n) {cout<<"int"<<endl;} void foo(int2type<0> a) {cout << "int2ty...


#add_pointer #type #template #remove_pointer #primary #is_pointer #is_array #int2type #extent #typedef

원문링크 : [정리]int2type