[ create a new paste ] login | about

Link: http://codepad.org/rc48PS6D    [ raw code | output | fork ]

C++, pasted on Sep 7:
#include <iostream>
#include <vector>
#include <typeinfo>
using namespace std;

template <class T>
void foo(T oh)
{
	vector<int> s;
	vector<vector<int> > d;

	if (typeid(s) == typeid(T)) {
		cout << "s" << endl;
	} else if (typeid(d) == typeid(T)) {
		cout << "d" << endl;
	} else {
		cout << "oops" << endl;
	}
}

int main(void)
{
	vector<int> bar1; bar1.push_back(8);
	vector<vector<int> > bar2; bar2.push_back(bar1);
	foo<vector<int> >(bar1);
	foo<vector<vector<int> > >(bar2);
	return 0;
}


Output:
1
2
s
d


Create a new paste based on this one


Comments: