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?
§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
frienddeclaration, the identifier is declared in the smallest namespace or block scope that contains the declaration.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With