https://github.com/root-project/root
Raw File
Tip revision: dc23f9fcef6b528a41995f8ce10463d5330581e6 authored by Fons Rademakers on 27 October 2012, 21:18:24 UTC
tag patch release v5-34-03.
Tip revision: dc23f9f
t927.cxx
/* -*- C++ -*- */
/*************************************************************************
 * Copyright(c) 1995~2005  Masaharu Goto (root-cint@cern.ch)
 *
 * For the licensing terms see the file COPYING
 *
 ************************************************************************/
#include <cstdio>
#include <vector>
#include <list>
#include <typeinfo>
using namespace std;


template<class T>
void func(T dmy) {
  vector<T> x;
  for(int i=0;i<5;i++) {
    x.push_back((T)i);
  }
  typename vector<T>::iterator first = x.begin();
  typename vector<T>::iterator last  = x.end();

  while(first!=last) {
     T tmp = *first++;
     printf("%d ",(int)(tmp));
  }
  printf("%s\n",typeid(x).name());
}

template<class T>
void lfunc(T dmy) {
  list<T> x;
  for(int i=0;i<5;i++) {
    x.push_back((T)i);
  }
  typename list<T>::iterator first = x.begin();
  typename list<T>::iterator last  = x.end();

  while(first!=last) {
     printf("%d ",(int)*first++);
  }
  printf("%s\n",typeid(x).name());
}

main() {
  func(double());
  func(float());
  func(int());
  func(char());
  func(short());
  func(long());
#if 1
  func((unsigned int)0);
  func((unsigned char)0);
  func((unsigned short)0);
  func((unsigned long)0);
#endif

  lfunc(double());
  lfunc(int());
  lfunc(long());
  lfunc(float());
#if 0
  // Need to compile list containers
  lfunc(char());
  lfunc(short());
#endif
}

back to top