All pastes #620622 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-07-15 17:05 UTC
rendered paste body
yabo@shuttle ~ $ g++ gest.cc
yabo@shuttle ~ $ ./a.out 
42
yabo@shuttle ~ $ g++ -DAMD64 gest.cc
yabo@shuttle ~ $ ./a.out 
Amd64 : 42
yabo@shuttle ~ $ cat gest.cc 
#include <iostream>

// Default : ia32
#define CURRENT_ARCH ia32

#ifdef AMD64
# undef CURRENT_ARCH
# define CURRENT_ARCH amd64
#endif

struct  ia32 {};
struct  amd64 {};

template<class Archi>
class gest_output
{
  public:
    void print_int(int  arg) const;
};

template<class Archi>
void gest_output<Archi>::print_int(int  arg) const
{
  std::cout << arg << std::endl;
}

template<>
void gest_output<amd64>::print_int(int  arg) const
{
  std::cout << "Amd64 : " << arg << std::endl;
}

int main()
{
  gest_output<CURRENT_ARCH> out;

  out.print_int(42);
}
yabo@shuttle ~ $