5

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?

0

1 Answer 1

6

§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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.