- sizeof 在編譯時,可以知道類大小
- 兩個類比較之後,等到一個常數
- 用這個常數結合模板實現
#include<iostream>
using namespace std;
class A {
int a;
};
class B {
int a;
int b;
};
template<int c> struct Comp;
template<>
struct Comp<1> {
Comp() {
#pragma message("less")
}
};
Comp < sizeof(A) < sizeof(B) > comp;
int main()
{
return 0;
}