~ubuntu-branches/ubuntu/trusty/c++-annotations/trusty

« back to all changes in this revision

Viewing changes to yo/friends/extended.yo

  • Committer: Package Import Robot
  • Author(s): Frank B. Brokken
  • Date: 2012-01-20 11:53:17 UTC
  • mfrom: (1.1.18)
  • Revision ID: package-import@ubuntu.com-20120120115317-v4wiq9sttx72fabk
Tags: 9.1.0-1
New upstream release (covering C++11 to a large extend)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
C++11 simplifies tt(friend) declarations by adding 
 
2
    emi(extended friend) em(declarations) 
 
3
    hi(friend: extended declaration)
 
4
        to the language. When a class is declared as a friend, then the
 
5
tt(class) keyword no longer has to be provided. E.g.,
 
6
        verb(
 
7
    class Friend;                   // declare a class
 
8
    typedef Friend FriendType;      // and a typedef for it
 
9
    using FName = Friend;           // and a using declaration
 
10
 
 
11
    class Class1
 
12
    {
 
13
        friend Friend;              // FriendType and FNaem: also OK
 
14
    };
 
15
        )
 
16
In the pre-C++11 standards the friend declaration required an explicit
 
17
tt(class); e.g., tt(friend class Friend). 
 
18
    
 
19
The explicit use of tt(class) remains required if the compiler hasn't seen
 
20
the friend's name yet. E.g.,
 
21
        verb(
 
22
    class Class1
 
23
    {
 
24
        // friend Unseen;           // fails to compile: Unseen unknown.
 
25
        friend class Unseen;        // OK
 
26
    };
 
27
        )    
 
28
Section ref(TEMPFRIENDS) covers the use of extended friend declarations in
 
29
class templates.