テンプレートパラメータで型パラメータを宣言した直後にその型のオブジェクトを非型パラメータとして宣言する

どうでも良いけどタイトル長っ!

template<class T, T t>
class C{};

C<int, 0> c_int;
C<void*, 0> c_void_ptr;

テンプレート型パラメータを宣言した直後にその型パラメータのオブジェクトを非型パラメータに指定出来るのって標準で保証されていたのね.


14.1 Template parameters

13 The scope of a template-parameter extends from its point of declaration until the end of its template. In particular, a template-parameter can be used in the declaration of subsequent template-parameters and their default arguments. [Example:

template class X { /* ... */ };
template void f(T* p = new T);
—end example]
これが保証されているならずっと考えてたあることが堂々と出来る・・・うしし.