c++0x decltype

#include <iostream>
#include <limits>
#include <typeinfo>
using std::cout;
using std::endl;
using std::numeric_limits;
using std::type_info;
//using std::decltype;    // 不要

int main()
{
	cout << numeric_limits<int>::max() << endl;

	int foo;
	cout << numeric_limits<decltype(foo)>::max() << endl;
//	cout << decltype(foo) << endl;
	// コンパイルエラー
	//     error: expected primary-expression before ‘decltype’
	//     error: expected ‘;’ before ‘decltype’

//	printf("%s\n", decltype(foo));
	// コンパイルエラー
	//     error: expected primary-expression before ‘decltype’

	const type_info *info = &typeid(foo);
//	cout << numeric_limits<info->name()>::max() << endl;
	// コンパイルエラー
	//     error: ‘info’ cannot appear in a constant-expression
	//     error: ‘->’ cannot appear in a constant-expression
	//     error: a function call cannot appear in a constant-expression
	//     error: template argument 1 is invalid

	return 0;
}

コンパイルする時は、

g++ -std=c++0x -Wall decltype.cc


RTTIということで混同してしまったけれど、
typeidとdecltypeは、違うものなのね。

decltypeの返り値(?)をテンプレート引数として使えるのは便利だな。
文字列としては出力できないのかな?