From: http://stackoverflow.com/questions/1708458/template-metaprogram-converting-type-to-unique-number
template < Prev, This>
= (Prev::position) + <>
TypeList<, >= <iostream>
< , > ;
typedef TypeList< , > t2;
typedef TypeList< t2, > t3;
<< << ::position <<<< << t2::position <<<< << t3::position <<
確實是非常巧妙的方法。這個方法在Andrei Alexandrescu的《Modern C++ Design》上有詳細說明。
這本書在豆瓣上的評分高達9.0,雖然比不上《The C Programming Language》的9.5,但卻比Herb Sutter的《Exceptional C++》的8.5分要高上不少。