Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

C++11 generalized attributes for namespaces

190 views
Skip to first unread message

Boris Kolpackov

unread,
Apr 8, 2012, 11:14:43 AM4/8/12
to
Hi,

I am looking into C++11 generalized attributes and trying to understand
if they apply to namespaces, including the global namespace/translation
unit.

According to Clause 7 [dcl.dcl] paragraph 1 (the attribute-declaration
production), we can have something like this:

[[attr]];

namespace n
{
[[attr]];
}

However, I can't seem to find any text that says what such an attribute
appertains to. Is it to the innermost namespace? Or, may be, always to
the translation unit?

Revision 4[1] of the Generalized Attributes paper had this paragraph:

"In an attribute-declaration, the attribute-specifier appertains to its
innermost enclosing namespace; if that namespace is the global namespace,
the attribute-specifier appertains to the entire translation unit. In an
attribute-specification, the attribute-specifier appertains to all entities
declared or named within the declaration-seq, if any. Multiple attribute-
specification nest. When they nest, for each attribute, the innermost one
determines the attribute effective for all entities in the declaration-seq.
An attribute-specification does not establish a scope."

However, in Revision 6[2] this paragraph has been removed.

I would appreciate it if someone can clarify this.

[1] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2553.pdf
[2] http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2761.pdf

Thanks,
Boris
--
Boris Kolpackov, Code Synthesis http://codesynthesis.com/~boris/blog
Compiler-based ORM system for C++ http://codesynthesis.com/products/odb
Open-source XML data binding for C++ http://codesynthesis.com/products/xsd
XML data binding for embedded systems http://codesynthesis.com/products/xsde


[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp...@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]

Daniel Krügler

unread,
Apr 12, 2012, 2:12:38 AM4/12/12
to
On 2012-04-08 17:14, Boris Kolpackov wrote:
>
> I am looking into C++11 generalized attributes and trying to understand
> if they apply to namespaces, including the global namespace/translation
> unit.
>
> According to Clause 7 [dcl.dcl] paragraph 1 (the attribute-declaration
> production), we can have something like this:
>
> [[attr]];
>
> namespace n
> {
> [[attr]];
> }
>
> However, I can't seem to find any text that says what such an attribute
> appertains to. Is it to the innermost namespace? Or, may be, always to
> the translation unit?


[..]

> I would appreciate it if someone can clarify this.


The semantics should be described by the general statement in 7 p1:

"Except where otherwise specified, the meaning of an
attribute-declaration is implementation-defined."

HTH & Greetings from Bremen,

Daniel Krügler


--
0 new messages