- Initializations involving braces - 1 Update
ram@zedat.fu-berlin.de (Stefan Ram): Nov 05 01:56AM >So, both examples are formally direct initialization, but the second one >involves a temporary instance of the class and is /effectively/ a copy >initialization. BTW & FWIW: I have just done an analysis of an initialization involving braces: { ::std::error_code const code{ 2, ::std::generic_category() }; } | ||| | || | | | | || | ||| | || | | || | | ||| | || | | | | || | LL'I' |'----- I ------' | || | | ||| | || | | | | || | | || | | || | | ||| | || | | | | || | '- L -''----- M ------' | || | | ||| | || | | | | || | | | | || | | ||| | || | | | | || | '--- qualified-id ----' | || | | ||| | || | | | | || | | | | || | | ||| | || | | | | || | '--- id-expression ---' | || | | ||| | || | | | | || | | | | || | | ||| | || | | | | || | '-primary-expression--' | || | | ||| | || | | | | || | | | | || | | ||| | || | | | | || K '-postfix-expression--' | || | | ||| | || | | | | || | | | || | | ||| | || | | | 'I-'| J '--postfix-expression --' || | | ||| | || | | | | || | | | || | | ||| | |'-- I ---' | | 'G-'| H ' assignment-expression ' || | | 9 'I' || | | | | || | | | || | | '-C-' |'-- D ---' | | 'E-'| F '- initializer-clause --' || | | | || | | | | || | | || | | '- 9 -''-- A ---' | | |B-'| '---- initializer-list ----' || | | | | | | | || || | | '------ 6 ------' '-7-' '8-''------ braced-init-list ------'| | | | | | | | || || | | '------ 4 ------' '-4-' '5-''- brace-or-equal-initializer -'| | | | | | | | || || | | '------ 2 ------' '-2-' '3-''-------- initializer ---------'| | | | | | | | || | | '------ 1 ------' '-1-' '-------- init-declarator ---------'| | | | | | || | | '--------- 0 ---------' '------ init-declarator-list ------'| | | | | | | '------------------- simple-declaration --------------------' | | | | | | '-------------------- block-declaration --------------------' | | | | | | '------------------ declaration-statement ------------------' | | | | | | '------------------------ statement ------------------------' | | | | | | '---------------------- statement-seq ----------------------' | | | '--------------------- compound statement ----------------------' M = unqualified-id L = nested-name-specifier K = literal J = conditional-expression I = identifier H = assignment-expression G = unqualified-id F = initializer-clause E = id-expression D = class-name C = namespace-name B = declarator-id A = type-name 9 = nested-name-specifier 8 = noptr-declarator 7 = cv-qualifier 6 = simple-type-specifier 5 = ptr-declarator 4 = trailing-type-specifier 3 = declarator 2 = type-specifier 1 = declaration-specifier 0 = decl-specifier-seq When one accepts to read lines with more than 72 characters per line, it might be more readable this way: { ::std::error_code const code{ 2, ::std::generic_category() }; } | ||| | || | | | | || | ||| | || | | || | | ||| | || | | | | || | LL'I' |'----- I ------' | || | | ||| | || | | | | || | | || | | || | | ||| | || | | | | || | '- L -''----- M ------' | || | | ||| | || | | | | || | | | | || | | ||| | || | | | | || | '--- qualified-id ----' | || | | ||| | || | | | | || | | | | || | | ||| | || | | | | || | '--- id-expression ---' | || | | ||| | || | | | | || | | | | || | | ||| | || | | | | || | '-primary-expression--' | || | | ||| | || | | | | || | | | | || | M = unqualified-id | ||| | || | | | | || K '-postfix-expression--' | || | L = nested-name-specifier | ||| | || | | | | || | | | || | K = literal | ||| | || | | | 'I-'| J '--postfix-expression --' || | J = conditional-expression | ||| | || | | | | || | | | || | I = identifier | ||| | |'-- I ---' | | 'G-'| H ' assignment-expression ' || | H = assignment-expression | 9 'I' || | | | | || | | | || | G = unqualified-id | '-C-' |'-- D ---' | | 'E-'| F '- initializer-clause --' || | F = initializer-clause | | || | | | | || | | || | E = id-expression | '- 9 -''-- A ---' | | |B-'| '---- initializer-list ----' || | D = class-name | | | | | | || || | C = namespace-name | '------ 6 ------' '-7-' '8-''------ braced-init-list ------'| | B = declarator-id | | | | | | || || | A = type-name | '------ 4 ------' '-4-' '5-''- brace-or-equal-initializer -'| | 9 = nested-name-specifier | | | | | | || || | 8 = noptr-declarator | '------ 2 ------' '-2-' '3-''-------- initializer ---------'| | 7 = cv-qualifier | | | | | | || | 6 = simple-type-specifier | '------ 1 ------' '-1-' '-------- init-declarator ---------'| | 5 = ptr-declarator | | | | || | 4 = trailing-type-specifier | '--------- 0 ---------' '------ init-declarator-list ------'| | 3 = declarator | | | | 2 = type-specifier | '------------------- simple-declaration --------------------' | 1 = declaration-specifier | | | | 0 = decl-specifier-seq | '-------------------- block-declaration --------------------' | | | | | | '------------------ declaration-statement ------------------' | | | | | | '------------------------ statement ------------------------' | | | | | | '---------------------- statement-seq ----------------------' | | | '--------------------- compound statement ----------------------' This message was written to be viewed with a fixed-width (monospaced) font and verbatim rendition of spaces and line breaks. The two "T" in the following two lines should be at the same horizontal position. IIIIIII...........|||||||||||||||"T" WWWWWWWWWWWWWWWWWWWWWWWWMMMMMMMMMMMMMMMMMMMMMMM"T" Lines with up to 78 characters should not be wrapped automatically, so there should be exactly two lines following this paragraph, where each line ends with an "I", and the two "I" are directly on top of each other: WWWW WWWW WWWW WWWW WWWW WWWW WWWW WWWW WWWW WWWW WWWW WWWW WWWW WWWW WWWW WI WI The following lines are indented, one exactly one space more than the preceding line. When this message is viewed or quoted, this property should be retained. The uppercase I should be aligned directly on top of each other. not indented I indented by 1 space I indented by 2 spaces I indented by 3 spaces I 0123 I not indented I indented by 1 space I indented by 2 spaces I indented by 3 spaces I 0123 I |
You received this digest because you're subscribed to updates for this group. You can change your settings on the group membership page. To unsubscribe from this group and stop receiving emails from it send an email to comp.lang.c+++unsubscribe@googlegroups.com. |
No comments:
Post a Comment