File: nesting.yo

package info (click to toggle)
c%2B%2B-annotations 8.2.0-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 11,804 kB
  • ctags: 2,845
  • sloc: cpp: 15,418; makefile: 2,473; ansic: 165; perl: 90; sh: 29
file content (101 lines) | stat: -rw-r--r-- 3,109 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
Namespaces can be nested. Here is an example:
        verb(
    namespace CppAnnotations
    {
        namespace Virtual
        {
            void *pointer;
        }
    }
        )
    The variable tt(pointer) is defined in the tt(Virtual) namespace, that
itself is nested under the tt(CppAnnotations) namespace. To refer to this
variable the following options are available:
    itemization(
    it() The emi(fully qualified name) can be used. A fully qualified name of
an entity is a list of all the namespaces that are encountered until reaching
the definition of the entity. The namespaces and entity are glued together by
the scope resolution operator:
        verb(
    int main()
    {
        CppAnnotations::Virtual::pointer = 0;
    }
        )
        it() A tt(using) declaration for tt(CppAnnotations::Virtual) can be
provided. Now tt(Virtual) can be used without any prefix, but
tt(pointer) must be used with the tt(Virtual::) prefix:
        verb(
    using CppAnnotations::Virtual;

    int main()
    {
        Virtual::pointer = 0;
    }
        )
        it() A tt(using) declaration for tt(CppAnnotations::Virtual::pointer)
can be used. Now tt(pointer) can be used without any prefix:
        verb(
    using CppAnnotations::Virtual::pointer;

    int main()
    {
        pointer = 0;
    }
        )
        it() A tt(using) directive or directives can be used:
        verb(
    using namespace CppAnnotations::Virtual;

    int main()
    {
        pointer = 0;
    }
        )
    Alternatively, two separate tt(using) directives could have been used:
        verb(
    using namespace CppAnnotations;
    using namespace Virtual;

    int main()
    {
        pointer = 0;
    }
        )
        it() A combination of tt(using) declarations and tt(using)
directives can be used. E.g., a tt(using) directive can be used for
the tt(CppAnnotations) namespace, and a tt(using) declaration can be used for
the tt(Virtual::pointer) variable:
        verb(
    using namespace CppAnnotations;
    using Virtual::pointer;

    int main()
    {
        pointer = 0;
    }
        )
    )

    At every tt(using) directive all entities of that namespace can be used
without any further prefix. If a namespace is nested, then that namespace can
also be used without any further prefix. However, the entities defined in the
nested namespace still need the nested namespace's name. Only after applying a
tt(using) declaration or directive the qualified name of the nested namespace
can be omitted.

    When fully qualified names are preferred but a long name like
                   centt(CppAnnotations::Virtual::pointer)
    is nevertheless considered too long, a emi(namespace alias) may be used:
                centt(namespace CV = CppAnnotations::Virtual;)
    This defines tt(CV) as an em(alias) for the full name. The
variable tt(pointer) may now be accessed using:
        verb(
    CV::pointer = 0;
        )
    A namespace alias can also be used in a tt(using) declaration or
directive:
        verb(
    namespace CV = CppAnnotations::Virtual;
    using namespace CV;
        )