Skip to main contentdfsdf

Geoffrey Fulton's List: CPlusPlus Reference

  • Apr 20, 10

    Legendary Bjarne Stroustrup's C++ glossary, incredibly exhaustive.

  • Apr 20, 10

    Highlighted ISO definition of C++ reference type in wiki cause I can be lazy sometimes.

    • ISO definition

       

      References are defined by the ISO C++ standard as follows (excluding the example section):

       
       

      In a declaration T D where D has the form

       
       
       
      & D1 
       
       

      and the type of the identifier in the declaration T D1 is “derived-declarator-type-list T,” then the type of the identifier of D is “derived-declarator-type-list reference to T.” Cv-qualified references are ill-formed except when the cv-qualifiers (const and volatile) are introduced through the use of a typedef (7.1.3) or of a template type argument (14.3), in which case the cv-qualifiers are ignored. [Example: in

       
       
       
      typedef int& A; const A aref = 3; // ill-formed; // non-const reference initialized with rvalue 
       
       

      the type of aref is “reference to int”, not “const reference to int”. ] [Note: a reference can be thought of as a name of an object. ] A declarator that specifies the type “reference to cv void” is ill-formed.

       

      It is unspecified whether or not a reference requires storage (3.7).

       

      There shall be no references to references, no arrays of references, and no pointers to references. The declaration of a reference shall contain an initializer (8.5.3) except when the declaration contains an explicit extern specifier (7.1.1), is a class member (9.2) declaration within a class declaration, or is the declaration of a parameter or a return type (8.3.5); see 3.1. A reference shall be initialized to refer to a valid object or function. [Note: in particular, a null reference cannot exist in a well-defined program, because the only way to create such a reference would be to bind it to the “object” obtained by dereferencing a null pointer, which causes undefined behavior. As described in 9.6, a reference cannot be bound directly to a bitfield. ]

       

      —ISO/IEC 14882:1998(E), the ISO C++ standard, in section 8.3.2 [dcl.ref]

1 - 3 of 3
20 items/page
List Comments (0)