Changeset 666

Show
Ignore:
Timestamp:
03/27/08 02:31:40 (10 months ago)
Author:
walter
Message:

hung more flesh on the bones

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/docsrc/cpp0x.dd

    r665 r666  
    77    C++ is undergoing an upgrade to a new standard, commonly referred 
    88    to as C++0x. 
    9     Here is the 
    10     $(LINK2 $(NDOCS)2008/n2565.html, current status of C++0x). 
    11     This article covers the highlights of C++0x core language changes 
     9    This article covers the highlights of 
     10    $(LINK2 $(NDOCS)2008/n2565.html, C++0x core language changes) 
    1211    and compares them with what is available in D. 
    13     Since C++0x is far from being finalized and is a moving target, 
    14     this article cannot be precise about it. 
     12    Since C++0x is far from being finalized, 
     13    this article is subject to being obsoleted by new proposals and 
     14    revisions to existing ones. 
     15    C++0x standard library changes are not addressed here. 
     16    TBD means To Be Determined. 
    1517    ) 
    1618 
     
    114116$(SECTION3 $(LNAME2 template-aliases, Template aliases for C++), 
    115117 
    116     $(P $(LINK2 $(NDOCS)2007/n2258.pdf, N2258): TBD 
    117     ) 
    118  
     118    $(P $(LINK2 $(NDOCS)2007/n2258.pdf, N2258): 
     119    Both $(LINK2 template.html, templates and template instantiations) 
     120    can be $(LINK2 declaration.html#alias, aliased): 
     121    ) 
     122--- 
     123struct S(T) { T int; } 
     124alias S X;       // alias template 
     125alias S!(int) Y; // alias template instantiation 
     126X!(int) x; 
     127Y y;  // x and y are the same type 
     128--- 
    119129) 
    120130 
     
    158168$(SECTION3 $(LNAME2 strong-enums, Strongly Typed Enums), 
    159169 
    160     $(P $(LINK2 $(NDOCS)2007/n2347.pdf, N2347): TBD 
     170    $(P $(LINK2 $(NDOCS)2007/n2347.pdf, N2347): 
     171    D $(LINK2 enum.html, enums) are: 
     172    ) 
     173 
     174    $(OL 
     175    $(LI Comparisons between different enum types should be an error, 
     176    but is not: 
     177--- 
     178void main() { 
     179    enum Color { ClrRed, ClrOrange, ClrYellow, ClrGreen, ClrBlue, ClrViolet }; 
     180    enum Alert { CndGreen, CndYellow, CndRed }; 
     181    Color c = Color.ClrRed; 
     182    Alert a = Alert.CndGreen; 
     183    a = c; // error 
     184    a = Color.ClrYellow; // error 
     185    bool armWeapons = ( a >= Color.ClrYellow ); // ok; oops 
     186
     187--- 
     188    ) 
     189    $(LI The underlying type can be specified.) 
     190    $(LI Named enums are strongly scoped. Anonymous enum members are 
     191    declared in the enclosing scope.) 
     192    $(LI Explicit qualification is needed to specify a named enum 
     193    member.) 
    161194    ) 
    162195 
     
    181214$(SECTION3 $(LNAME2 constant-expressions, Generalized Constant Expressions), 
    182215 
    183     $(P $(LINK2 $(NDOCS)2007/n2235.pdf, N2235): TBD 
     216    $(P $(LINK2 $(NDOCS)2007/n2235.pdf, N2235): 
     217    D has $(LINK2 function.html#interpretation, compile time function execution) 
     218    (CTFE). CTFE is much more flexible, as functions to be evaluated 
     219    at compile time: 
     220    ) 
     221 
     222    $(OL 
     223    $(LI do not require a special keyword (C++0x requires $(CODE constexpr))) 
     224    $(LI can have multiple statements in the function) 
     225    $(LI can be recursive) 
     226    $(LI can modify local variables) 
     227    $(LI can have out parameters) 
    184228    ) 
    185229 
     
    188232$(SECTION3 $(LNAME2 namespace-association, Namespace Association ("Strong Using")), 
    189233 
    190     $(P $(LINK2 $(NDOCS)2008/n2535.html, N2535): TBD 
     234    $(P $(LINK2 $(NDOCS)2008/n2535.html, N2535): 
     235    D doesn't have namespaces, 
     236    so this is irrelevant. 
    191237    ) 
    192238 
     
    196242 
    197243    $(P $(LINK2 $(NDOCS)2004/n1653.htm, N1653): 
    198     D has no text preprocessor, so this is not relevant to D. 
     244    D does not have a preprocessor, 
     245    so this is not relevant to D. 
    199246    ) 
    200247 
     
    215262$(SECTION3 $(LNAME2 conditional, Conditionally-Supported Behavior), 
    216263 
    217     $(P $(LINK2 $(NDOCS)2004/n1627.pdf, N1627): TBD 
     264    $(P $(LINK2 $(NDOCS)2004/n1627.pdf, N1627): 
     265    There are some allowed vendor specific behaviors in D, 
     266    such as $(LINK2 pragma.html, pragmas). 
    218267    ) 
    219268 
     
    222271$(SECTION3 $(LNAME2 undefined-behavior, Changing Undefined Behavior into Diagnosable Errors), 
    223272 
    224     $(P $(LINK2 $(NDOCS)2004/n1727.pdf, N1727): TBD 
     273    $(P $(LINK2 $(NDOCS)2004/n1727.pdf, N1727): 
     274    D does not have undefined behavior with integer literal types, 
     275    character escapes, or passing non-POD objects to ellipses. 
    225276    ) 
    226277 
     
    250301$(SECTION3 $(LNAME2 delegating-ctors, Delegating Constructors), 
    251302 
    252     $(P $(LINK2 $(NDOCS)2006/n1986.pdf, N1986): TBD 
     303    $(P $(LINK2 $(NDOCS)2006/n1986.pdf, N1986): 
     304    D has 
     305    $(LINK2 class.html#delegating-constructors, delegating constructors). 
    253306    ) 
    254307 
     
    285338$(SECTION3 $(LNAME2 type-deduction, Deducing the type of variable from its initializer expression), 
    286339 
    287     $(P $(LINK2 $(NDOCS)2006/n1984.pdf, N1984): TBD 
     340    $(P $(LINK2 $(NDOCS)2006/n1984.pdf, N1984): 
     341    D has $(LINK2 declaration.html#AutoDeclaration, type inference) 
     342    from initializers. 
    288343    ) 
    289344 
     
    292347$(SECTION3 $(LNAME2 auto-declarations, The Syntax of auto Declarations), 
    293348 
    294     $(P $(LINK2 $(NDOCS)2008/n2546.html, N2546): TBD 
     349    $(P $(LINK2 $(NDOCS)2008/n2546.html, N2546): 
     350    D $(LINK2 attribute.html#auto, auto declarations) 
     351    do not have syntactic issues. 
    295352    ) 
    296353 
     
    313370$(SECTION3 $(LNAME2 lambda, (monomorphic) Lambda expressions and closures for C++), 
    314371 
    315     $(P $(LINK2 $(NDOCS)2008/n2550.pdf, N2550): TBD 
     372    $(P $(LINK2 $(NDOCS)2008/n2550.pdf, N2550): 
     373    D has $(LINK2 expression.html#FunctionLiteral, lambda expressions) and 
     374    $(LINK2 function.html#closures, closures). 
    316375    ) 
    317376 
     
    341400$(SECTION3 $(LNAME2 raw-strings, Raw String Literals), 
    342401 
    343     $(P $(LINK2 $(NDOCS)2007/n2442.html, N2442): TBD 
     402    $(P $(LINK2 $(NDOCS)2007/n2442.html, N2442): 
     403    D has $(LINK2 lex.html#StringLiteral, wysiwyg and delimited strings), 
     404    and all strings are Unicode. 
    344405    ) 
    345406 
     
    348409$(SECTION3 $(LNAME2 pod, PODs unstrung), 
    349410 
    350     $(P $(LINK2 $(NDOCS)2007/n2342.html, N2342): TBD 
     411    $(P $(LINK2 $(NDOCS)2007/n2294.html, N2294): 
     412    All D $(LINK2 struct.html, structs) are 
     413    $(LINK2 glossary.html#pod, POD (Plain Old Data)). 
     414    D $(LINK2 class.html, classes) are reference, polymorphic types. 
    351415    ) 
    352416 
     
    439503$(SECTION3 $(LNAME2 return-types, New function declaration syntax for deduced return types), 
    440504 
    441     $(P $(LINK2 $(NDOCS)2008/n2541.html, N2541): TBD 
     505    $(P $(LINK2 $(NDOCS)2007/n2445.html, N2445): TBD 
    442506    ) 
    443507 
     
    453517$(SECTION3 $(LNAME2 local-classes, Making Local Classes more Useful), 
    454518 
    455     $(P $(LINK2 $(NDOCS)2007/n2402.pdf, N2402): TBD 
     519    $(P $(LINK2 $(NDOCS)2007/n2402.pdf, N2402): 
     520    D has no restrictions on using local classes as template 
     521    parameters. 
    456522    ) 
    457523 
     
    460526$(SECTION3 $(LNAME2 initializer-lists, Initializer lists), 
    461527 
    462     $(P $(LINK2 $(NDOCS)2008/n2531.pdf, N2531): TBD 
     528    $(P $(LINK2 $(NDOCS)2008/n2531.pdf, N2531): 
     529    D has 
     530    $(LINK2 struct.html#StructLiteral, struct literals), 
     531    $(LINK2 expression.html#ArrayLiteral, array literals), 
     532    and $(LINK2 expression.html#AssocArrayLiteral, associative array literals). 
    463533    ) 
    464534 
     
    475545$(SECTION3 $(LNAME2 member-initializers, Member Initializers), 
    476546 
    477     $(P $(LINK2 $(NDOCS)2007/n2426.htm, N2426): TBD 
     547    $(P $(LINK2 $(NDOCS)2007/n2426.htm, N2426): 
     548    D has 
     549    $(LINK2 class.html#class-default-initializer, member initializers), 
     550    which are called $(I default initializers). 
    478551    ) 
    479552 
     
    498571$(SECTION3 $(LNAME2 general-attributes, General Attributes for C++), 
    499572 
    500     $(P $(LINK2 $(NDOCS)2007/n2418.pdf, N2418): TBD 
     573    $(P $(LINK2 $(NDOCS)2007/n2418.pdf, N2418): 
     574    Vendor specific attributes can be applied to statements 
     575    and declarations with 
     576    $(LINK2 pragma.html, pragmas). 
    501577    ) 
    502578 
     
    505581$(SECTION3 $(LNAME2 extensible-literals, Extensible Literals), 
    506582 
    507     $(P $(LINK2 $(NDOCS)2007/n2378.pdf, N2378): TBD 
     583    $(P $(LINK2 $(NDOCS)2007/n2378.pdf, N2378): 
     584    D does not have user extensible literals. 
    508585    ) 
    509586 
     
    532609$(SECTION3 $(LNAME2 forward-enums, Forward declaration of enumerations), 
    533610 
    534     $(P $(LINK2 $(NDOCS)2008/n2499.pdf, N2499): TBD 
     611    $(P $(LINK2 $(NDOCS)2008/n2499.pdf, N2499): 
     612    Forward declarations are not necessary in D, as all declarations 
     613    are resolved essentially in parallel. 
     614    Incomplete $(LINK2 enum.html, enum) types, however, are possible: 
     615    ) 
     616--- 
     617enum E : int; 
     618--- 
     619    $(P where the member values are hidden from the user. 
    535620    ) 
    536621