Changeset 666
- Timestamp:
- 03/27/08 02:31:40 (10 months ago)
- Files:
-
- trunk/docsrc/cpp0x.dd (modified) (21 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/docsrc/cpp0x.dd
r665 r666 7 7 C++ is undergoing an upgrade to a new standard, commonly referred 8 8 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) 12 11 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. 15 17 ) 16 18 … … 114 116 $(SECTION3 $(LNAME2 template-aliases, Template aliases for C++), 115 117 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 --- 123 struct S(T) { T int; } 124 alias S X; // alias template 125 alias S!(int) Y; // alias template instantiation 126 X!(int) x; 127 Y y; // x and y are the same type 128 --- 119 129 ) 120 130 … … 158 168 $(SECTION3 $(LNAME2 strong-enums, Strongly Typed Enums), 159 169 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 --- 178 void 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.) 161 194 ) 162 195 … … 181 214 $(SECTION3 $(LNAME2 constant-expressions, Generalized Constant Expressions), 182 215 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) 184 228 ) 185 229 … … 188 232 $(SECTION3 $(LNAME2 namespace-association, Namespace Association ("Strong Using")), 189 233 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. 191 237 ) 192 238 … … 196 242 197 243 $(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. 199 246 ) 200 247 … … 215 262 $(SECTION3 $(LNAME2 conditional, Conditionally-Supported Behavior), 216 263 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). 218 267 ) 219 268 … … 222 271 $(SECTION3 $(LNAME2 undefined-behavior, Changing Undefined Behavior into Diagnosable Errors), 223 272 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. 225 276 ) 226 277 … … 250 301 $(SECTION3 $(LNAME2 delegating-ctors, Delegating Constructors), 251 302 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). 253 306 ) 254 307 … … 285 338 $(SECTION3 $(LNAME2 type-deduction, Deducing the type of variable from its initializer expression), 286 339 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. 288 343 ) 289 344 … … 292 347 $(SECTION3 $(LNAME2 auto-declarations, The Syntax of auto Declarations), 293 348 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. 295 352 ) 296 353 … … 313 370 $(SECTION3 $(LNAME2 lambda, (monomorphic) Lambda expressions and closures for C++), 314 371 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). 316 375 ) 317 376 … … 341 400 $(SECTION3 $(LNAME2 raw-strings, Raw String Literals), 342 401 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. 344 405 ) 345 406 … … 348 409 $(SECTION3 $(LNAME2 pod, PODs unstrung), 349 410 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. 351 415 ) 352 416 … … 439 503 $(SECTION3 $(LNAME2 return-types, New function declaration syntax for deduced return types), 440 504 441 $(P $(LINK2 $(NDOCS)200 8/n2541.html, N2541): TBD505 $(P $(LINK2 $(NDOCS)2007/n2445.html, N2445): TBD 442 506 ) 443 507 … … 453 517 $(SECTION3 $(LNAME2 local-classes, Making Local Classes more Useful), 454 518 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. 456 522 ) 457 523 … … 460 526 $(SECTION3 $(LNAME2 initializer-lists, Initializer lists), 461 527 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). 463 533 ) 464 534 … … 475 545 $(SECTION3 $(LNAME2 member-initializers, Member Initializers), 476 546 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). 478 551 ) 479 552 … … 498 571 $(SECTION3 $(LNAME2 general-attributes, General Attributes for C++), 499 572 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). 501 577 ) 502 578 … … 505 581 $(SECTION3 $(LNAME2 extensible-literals, Extensible Literals), 506 582 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. 508 585 ) 509 586 … … 532 609 $(SECTION3 $(LNAME2 forward-enums, Forward declaration of enumerations), 533 610 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 --- 617 enum E : int; 618 --- 619 $(P where the member values are hidden from the user. 535 620 ) 536 621
