Int2Type 使用示例

#include <cstdlib>
#include <iostream>
using namespace std;
template<int v>
struct Int2Type
{
  enum{value = v};
};

void Do(Int2Type<0>* t)
{
  cout<<"0:"<<t->value<<endl;
  delete t;
};
void Do(Int2Type<1>* t)
{
  cout<<"1:"<<t->value<<endl;
  delete t;
};
void Do(Int2Type<2>* t)
{
  cout<<"2:"<<t->value<<endl;
  delete t;
};
int main(int argc, char *argv[])
{
    Do(new Int2Type<0>);
    Do(new Int2Type<1>);
    Do(new Int2Type<2>);
    system("PAUSE");
    return EXIT_SUCCESS;
}

你可能感兴趣的:(delete,System,include)