Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I have seen use like:

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

Here tag_name names an incomplete type and the struct keyword preceding it seems to declare it in-place, instead of the slightly more verbose:

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

What is the relevant part of the standard that allows this?

like image 714
CppNoob Avatar asked Apr 23 '15 15:04

CppNoob


1 Answers

§3.4.4/2 specifies how elaborated-type-specifiers, in any situation, are looked up and what effect they may have:

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.

Then §3.3.2/7(.2) reads

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.

like image 67
Columbo Avatar answered Sep 30 '22 13:09

Columbo