在参数列表中就地声明不完整的类型模板参数

Declaring an incomplete type template parameter in place in-the argument list

我见过这样的用法:

boost::error_info<struct tag_name, std::string> name_info;

这里 tag_name 命名了一个不完整的类型,它前面的 struct 关键字似乎就地声明了它,而不是稍微冗长一些:

struct tag_name;
boost::error_info<tag_name, std::string> name_info;

允许这样做的标准的相关部分是什么?

§3.4.4/2 指定在任何情况下如何查找详细类型说明符以及它们可能产生的影响:

If the elaborated-type-specifier is introduced by the class-key and this lookup does not find a previously declared type-name [..] the elaborated-type-specifier is a declaration that introduces the class-name as described in 3.3.2.

然后 §3.3.2/7(.2) 读取

The point of declaration of a class first declared in an elaborated-type-specifier is as follows: [..] for an elaborated-type-specifier of the form

         class-key identifier

if the elaborated-type-specifier is used in the decl-specifier-seq or parameter-declaration-clause of a function defined in namespace scope, the identifier is declared as a class-name in the namespace that contains the declaration; otherwise, except as a friend declaration, the identifier is declared in the smallest namespace or block scope that contains the declaration.