| 1 |
Ddoc |
|---|
| 2 |
|
|---|
| 3 |
$(COMMUNITY D and C++0x, |
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
$(P |
|---|
| 7 |
C++ is undergoing an upgrade to a new standard, commonly referred |
|---|
| 8 |
to as C++0x. |
|---|
| 9 |
This article covers the highlights of |
|---|
| 10 |
$(LINK2 $(NDOCS)2008/n2597.html, C++0x core language changes) |
|---|
| 11 |
and compares them with what is available in D. |
|---|
| 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. |
|---|
| 17 |
) |
|---|
| 18 |
|
|---|
| 19 |
$(SECTION3 Proposed C++0x Features, |
|---|
| 20 |
|
|---|
| 21 |
$(UL |
|---|
| 22 |
$(LI $(LINK2 #rvalue-reference, A Proposal to Add an Rvalue Reference to the C++ Language)) |
|---|
| 23 |
$(LI $(LINK2 #class-rvalue, Clarification of Initialization of Class Objects by rvalues)) |
|---|
| 24 |
$(LI $(LINK2 #move-semantics, Extending Move Semantics To *this (Revision 2))) |
|---|
| 25 |
$(LI $(LINK2 #static-assert, static_assert)) |
|---|
| 26 |
$(LI $(LINK2 #template-aliases, Template aliases for C++)) |
|---|
| 27 |
$(LI $(LINK2 #extern-template, Extern template)) |
|---|
| 28 |
$(LI $(LINK2 #variadic-templates, Variadic Templates)) |
|---|
| 29 |
$(LI $(LINK2 #variadic-template-templates, Extending Variadic Template Template Parameters)) |
|---|
| 30 |
$(LI $(LINK2 #nullptr, A name for the null pointer: nullptr)) |
|---|
| 31 |
$(LI $(LINK2 #strong-enums, Strongly Typed Enums)) |
|---|
| 32 |
$(LI $(LINK2 #extended-friends, Extended friend Declarations)) |
|---|
| 33 |
$(LI $(LINK2 #constant-expressions, Generalized Constant Expressions)) |
|---|
| 34 |
$(LI $(LINK2 #namespace-association, Namespace Association ("Strong Using"))) |
|---|
| 35 |
$(LI $(LINK2 #c99-preprocessor, Synchronizing the C++ preprocessor with C99)) |
|---|
| 36 |
$(LI $(LINK2 #alignment, Adding Alignment Support to the C++ Programming Language)) |
|---|
| 37 |
$(LI $(LINK2 #conditional, Conditionally-Supported Behavior)) |
|---|
| 38 |
$(LI $(LINK2 #undefined-behavior, Changing Undefined Behavior into Diagnosable Errors)) |
|---|
| 39 |
$(LI $(LINK2 #long-long, Adding the long long type to C++)) |
|---|
| 40 |
$(LI $(LINK2 #extended-integer-types, Adding extended integer types to C++)) |
|---|
| 41 |
$(LI $(LINK2 #delegating-ctors, Delegating Constructors)) |
|---|
| 42 |
$(LI $(LINK2 #explicit-conversion, Explicit Conversion Operators)) |
|---|
| 43 |
$(LI $(LINK2 #char16_t, New Character Types in C++)) |
|---|
| 44 |
$(LI $(LINK2 #right-angle-brackets, Right Angle Brackets)) |
|---|
| 45 |
$(LI $(LINK2 #type-deduction, Deducing the type of variable from its initializer expression)) |
|---|
| 46 |
$(LI $(LINK2 #auto-declarations, The Syntax of auto Declarations)) |
|---|
| 47 |
$(LI $(LINK2 #inheriting-ctors, Inheriting Constructors)) |
|---|
| 48 |
$(LI $(LINK2 #sequence-points, A finer-grained alternative to sequence points)) |
|---|
| 49 |
$(LI $(LINK2 #lambda, (monomorphic) Lambda expressions and closures for C++)) |
|---|
| 50 |
$(LI $(LINK2 #__func__, Proposed addition of __func__ predefined identifier from C99)) |
|---|
| 51 |
$(LI $(LINK2 #atomic, Atomic operations with multi-threaded environments)) |
|---|
| 52 |
$(LI $(LINK2 #concurrency, Sequencing and the concurrency memory model)) |
|---|
| 53 |
$(LI $(LINK2 #raw-strings, Raw String Literals)) |
|---|
| 54 |
$(LI $(LINK2 #pod, PODs unstrung)) |
|---|
| 55 |
$(LI $(LINK2 #exceptions, Propagating exceptions when joining threads)) |
|---|
| 56 |
$(LI $(LINK2 #decltype, Decltype)) |
|---|
| 57 |
$(LI $(LINK2 #sizeof, Extending sizeof)) |
|---|
| 58 |
$(LI $(LINK2 #utf8-literals, UTF8 Literals)) |
|---|
| 59 |
$(LI $(LINK2 #ucs-in-literals, Universal Character Names in Literals)) |
|---|
| 60 |
$(LI $(LINK2 #defaulted, Defaulted and Deleted Functions)) |
|---|
| 61 |
$(LI $(LINK2 #unions, Unrestricted Unions)) |
|---|
| 62 |
$(LI $(LINK2 #library, A Multi-threading Library for Standard C++)) |
|---|
| 63 |
$(LI $(LINK2 #abandoning, Abandoning a Process)) |
|---|
| 64 |
$(LI $(LINK2 #return-types, New function declaration syntax for deduced return types)) |
|---|
| 65 |
$(LI $(LINK2 #atomic-signals, Allow atomics use in signal handlers)) |
|---|
| 66 |
) |
|---|
| 67 |
|
|---|
| 68 |
$(UL |
|---|
| 69 |
$(LI $(LINK2 #local-classes, Making Local Classes more Useful)) |
|---|
| 70 |
$(LI $(LINK2 #initializer-lists, Initializer lists)) |
|---|
| 71 |
$(LI $(LINK2 #thread-local-storage, Thread-Local Storage)) |
|---|
| 72 |
$(LI $(LINK2 #member-initializers, Member Initializers)) |
|---|
| 73 |
$(LI $(LINK2 #concepts, Concepts (unified proposal))) |
|---|
| 74 |
$(LI $(LINK2 #for-loop, Proposal for new for-loop)) |
|---|
| 75 |
$(LI $(LINK2 #general-attributes, General Attributes for C++)) |
|---|
| 76 |
) |
|---|
| 77 |
|
|---|
| 78 |
$(UL |
|---|
| 79 |
$(LI $(LINK2 #extensible-literals, Extensible Literals)) |
|---|
| 80 |
$(LI $(LINK2 #dynamic-concurrency, Dynamic initialization and concurrency)) |
|---|
| 81 |
$(LI $(LINK2 #garbage-collection, Minimal Support for Garbage Collection and Reachability-Based Leak Detection)) |
|---|
| 82 |
$(LI $(LINK2 #forward-enums, Forward declaration of enumerations)) |
|---|
| 83 |
) |
|---|
| 84 |
) |
|---|
| 85 |
|
|---|
| 86 |
$(SECTION3 $(LNAME2 rvalue-reference, A Proposal to Add an Rvalue Reference to the C++ Language), |
|---|
| 87 |
|
|---|
| 88 |
$(P $(LINK2 $(NDOCS)2005/n1770.html, N1770): TBD |
|---|
| 89 |
) |
|---|
| 90 |
|
|---|
| 91 |
) |
|---|
| 92 |
|
|---|
| 93 |
$(SECTION3 $(LNAME2 class-rvalue, Clarification of Initialization of Class Objects by rvalues), |
|---|
| 94 |
|
|---|
| 95 |
$(P $(LINK2 $(NDOCS)2004/n1610.html, N1610): TBD |
|---|
| 96 |
) |
|---|
| 97 |
|
|---|
| 98 |
) |
|---|
| 99 |
|
|---|
| 100 |
$(SECTION3 $(LNAME2 move-semantics, Extending Move Semantics To *this (Revision 2)), |
|---|
| 101 |
|
|---|
| 102 |
$(P $(LINK2 $(NDOCS)2007/n2439.htm, N2439): TBD |
|---|
| 103 |
) |
|---|
| 104 |
|
|---|
| 105 |
) |
|---|
| 106 |
|
|---|
| 107 |
$(SECTION3 $(LNAME2 static-assert, static_assert), |
|---|
| 108 |
|
|---|
| 109 |
$(P $(LINK2 $(NDOCS)2004/n1720.html, N1720): |
|---|
| 110 |
$(LINK2 version.html#StaticAssert, static assert) is |
|---|
| 111 |
part of D. |
|---|
| 112 |
) |
|---|
| 113 |
|
|---|
| 114 |
) |
|---|
| 115 |
|
|---|
| 116 |
$(SECTION3 $(LNAME2 template-aliases, Template aliases for C++), |
|---|
| 117 |
|
|---|
| 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 |
--- |
|---|
| 129 |
) |
|---|
| 130 |
|
|---|
| 131 |
$(SECTION3 $(LNAME2 extern-template, Extern template), |
|---|
| 132 |
|
|---|
| 133 |
$(P $(LINK2 $(NDOCS)2006/n1987.htm, N1987): |
|---|
| 134 |
This is a workaround for problems in the traditional compile/link |
|---|
| 135 |
build model. |
|---|
| 136 |
The D compiler deals with this by if multiple modules are compiled |
|---|
| 137 |
at the same time, only one instance of a template is generated |
|---|
| 138 |
for all the generated object files rather than one instance in each |
|---|
| 139 |
object file. Further improvements are planned for generating library |
|---|
| 140 |
modules that avoid multiple redundant template instantiations. |
|---|
| 141 |
) |
|---|
| 142 |
|
|---|
| 143 |
) |
|---|
| 144 |
|
|---|
| 145 |
$(SECTION3 $(LNAME2 variadic-templates, Variadic Templates), |
|---|
| 146 |
|
|---|
| 147 |
$(P $(LINK2 $(NDOCS)2007/n2242.pdf, N2242): |
|---|
| 148 |
D's $(LINK2 template.html#variadic-templates, variadic templates). |
|---|
| 149 |
) |
|---|
| 150 |
|
|---|
| 151 |
) |
|---|
| 152 |
|
|---|
| 153 |
$(SECTION3 $(LNAME2 variadic-template-templates, Extending Variadic Template Template Parameters), |
|---|
| 154 |
|
|---|
| 155 |
$(P $(LINK2 $(NDOCS)2008/n2555.pdf, N2555): TBD |
|---|
| 156 |
) |
|---|
| 157 |
|
|---|
| 158 |
) |
|---|
| 159 |
|
|---|
| 160 |
$(SECTION3 $(LNAME2 nullptr, A name for the null pointer: nullptr), |
|---|
| 161 |
|
|---|
| 162 |
$(P $(LINK2 $(NDOCS)2007/n2431.pdf, N2431): |
|---|
| 163 |
D has the $(LINK2 expression.html#null, null) equivalent. |
|---|
| 164 |
) |
|---|
| 165 |
|
|---|
| 166 |
) |
|---|
| 167 |
|
|---|
| 168 |
$(SECTION3 $(LNAME2 strong-enums, Strongly Typed Enums), |
|---|
| 169 |
|
|---|
| 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.) |
|---|
| 194 |
) |
|---|
| 195 |
|
|---|
| 196 |
) |
|---|
| 197 |
|
|---|
| 198 |
$(SECTION3 $(LNAME2 extended-friends, Extended friend Declarations), |
|---|
| 199 |
|
|---|
| 200 |
$(P $(LINK2 $(NDOCS)2005/n1791.pdf, N1791): |
|---|
| 201 |
All code in a module has |
|---|
| 202 |
$(LINK2 attribute.html#ProtectionAttribute, access) |
|---|
| 203 |
to private members |
|---|
| 204 |
of any struct or class declared in that module that is in |
|---|
| 205 |
scope. |
|---|
| 206 |
Package protected members can be accessed by any code in the |
|---|
| 207 |
same package. |
|---|
| 208 |
There is no need in D to have friend declarations or |
|---|
| 209 |
complex lookup rules for them. |
|---|
| 210 |
) |
|---|
| 211 |
|
|---|
| 212 |
) |
|---|
| 213 |
|
|---|
| 214 |
$(SECTION3 $(LNAME2 constant-expressions, Generalized Constant Expressions), |
|---|
| 215 |
|
|---|
| 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) |
|---|
| 228 |
) |
|---|
| 229 |
|
|---|
| 230 |
) |
|---|
| 231 |
|
|---|
| 232 |
$(SECTION3 $(LNAME2 namespace-association, Namespace Association ("Strong Using")), |
|---|
| 233 |
|
|---|
| 234 |
$(P $(LINK2 $(NDOCS)2008/n2535.html, N2535): |
|---|
| 235 |
D doesn't have namespaces, |
|---|
| 236 |
so this is irrelevant. |
|---|
| 237 |
) |
|---|
| 238 |
|
|---|
| 239 |
) |
|---|
| 240 |
|
|---|
| 241 |
$(SECTION3 $(LNAME2 c99-preprocessor, Synchronizing the C++ preprocessor with C99), |
|---|
| 242 |
|
|---|
| 243 |
$(P $(LINK2 $(NDOCS)2004/n1653.htm, N1653): |
|---|
| 244 |
D does not have a preprocessor, |
|---|
| 245 |
so this is not relevant to D. |
|---|
| 246 |
) |
|---|
| 247 |
|
|---|
| 248 |
) |
|---|
| 249 |
|
|---|
| 250 |
$(SECTION3 $(LNAME2 alignment, Adding Alignment Support to the C++ Programming Language), |
|---|
| 251 |
|
|---|
| 252 |
$(P $(LINK2 $(NDOCS)2007/n2341.pdf, N2341): |
|---|
| 253 |
D has the $(LINK2 attribute.html#align, align) |
|---|
| 254 |
attribute to specify the alignment |
|---|
| 255 |
of declarations, and the $(LINK2 property.html#alignof, .alignof) |
|---|
| 256 |
property to |
|---|
| 257 |
determine the alignment size of an expression or type. |
|---|
| 258 |
) |
|---|
| 259 |
|
|---|
| 260 |
) |
|---|
| 261 |
|
|---|
| 262 |
$(SECTION3 $(LNAME2 conditional, Conditionally-Supported Behavior), |
|---|
| 263 |
|
|---|
| 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). |
|---|
| 267 |
) |
|---|
| 268 |
|
|---|
| 269 |
) |
|---|
| 270 |
|
|---|
| 271 |
$(SECTION3 $(LNAME2 undefined-behavior, Changing Undefined Behavior into Diagnosable Errors), |
|---|
| 272 |
|
|---|
| 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. |
|---|
| 276 |
) |
|---|
| 277 |
|
|---|
| 278 |
) |
|---|
| 279 |
|
|---|
| 280 |
$(SECTION3 $(LNAME2 long-long, Adding the long long type to C++), |
|---|
| 281 |
|
|---|
| 282 |
$(P $(LINK2 $(NDOCS)2005/n1811.pdf, N1811): |
|---|
| 283 |
D's $(LINK2 type.html, long) type is equivalent. |
|---|
| 284 |
) |
|---|
| 285 |
|
|---|
| 286 |
) |
|---|
| 287 |
|
|---|
| 288 |
$(SECTION3 $(LNAME2 extended-integer-types, Adding extended integer types to C++), |
|---|
| 289 |
|
|---|
| 290 |
$(P $(LINK2 $(NDOCS)2006/n1988.pdf, N1988): |
|---|
| 291 |
D has the $(LINK2 type.html, cent and |
|---|
| 292 |
ucent) types for |
|---|
| 293 |
128 bit integral types (not implemented in dmd or gdc). |
|---|
| 294 |
There is no proposal for other extended |
|---|
| 295 |
integral types, but it's hard to imagine a justification for |
|---|
| 296 |
adding more to the core language. |
|---|
| 297 |
) |
|---|
| 298 |
|
|---|
| 299 |
) |
|---|
| 300 |
|
|---|
| 301 |
$(SECTION3 $(LNAME2 delegating-ctors, Delegating Constructors), |
|---|
| 302 |
|
|---|
| 303 |
$(P $(LINK2 $(NDOCS)2006/n1986.pdf, N1986): |
|---|
| 304 |
D has |
|---|
| 305 |
$(LINK2 class.html#delegating-constructors, delegating constructors). |
|---|
| 306 |
) |
|---|
| 307 |
|
|---|
| 308 |
) |
|---|
| 309 |
|
|---|
| 310 |
$(SECTION3 $(LNAME2 explicit-conversion, Explicit Conversion Operators), |
|---|
| 311 |
|
|---|
| 312 |
$(P $(LINK2 $(NDOCS)2007/n2437.html, N2437): TBD |
|---|
| 313 |
) |
|---|
| 314 |
|
|---|
| 315 |
) |
|---|
| 316 |
|
|---|
| 317 |
$(SECTION3 $(LNAME2 char16_t, New Character Types in C++), |
|---|
| 318 |
|
|---|
| 319 |
$(P $(LINK2 $(NDOCS)2007/n2249.html, N2249): |
|---|
| 320 |
C++0x adds new character types char16_t and char32_t, |
|---|
| 321 |
which are equivalent to D's $(LINK2 type.html, wchar and dchar types). |
|---|
| 322 |
The u and U character literal prefixes are equivalent to the |
|---|
| 323 |
D $(LINK2 lex.html#StringLiteral, w and d postfixes). |
|---|
| 324 |
) |
|---|
| 325 |
|
|---|
| 326 |
) |
|---|
| 327 |
|
|---|
| 328 |
$(SECTION3 $(LNAME2 right-angle-brackets, Right Angle Brackets), |
|---|
| 329 |
|
|---|
| 330 |
$(P $(LINK2 $(NDOCS)2005/n1757.html, N1757): |
|---|
| 331 |
Since D uses !( ) to instantiate templates rather than |
|---|
| 332 |
< >, there are no parsing ambiguities and |
|---|
| 333 |
no fixes are necessary. |
|---|
| 334 |
) |
|---|
| 335 |
|
|---|
| 336 |
) |
|---|
| 337 |
|
|---|
| 338 |
$(SECTION3 $(LNAME2 type-deduction, Deducing the type of variable from its initializer expression), |
|---|
| 339 |
|
|---|
| 340 |
$(P $(LINK2 $(NDOCS)2006/n1984.pdf, N1984): |
|---|
| 341 |
D has $(LINK2 declaration.html#AutoDeclaration, type inference) |
|---|
| 342 |
from initializers. |
|---|
| 343 |
) |
|---|
| 344 |
|
|---|
| 345 |
) |
|---|
| 346 |
|
|---|
| 347 |
$(SECTION3 $(LNAME2 auto-declarations, The Syntax of auto Declarations), |
|---|
| 348 |
|
|---|
| 349 |
$(P $(LINK2 $(NDOCS)2008/n2546.html, N2546): |
|---|
| 350 |
D $(LINK2 attribute.html#auto, auto declarations) |
|---|
| 351 |
do not have syntactic issues. |
|---|
| 352 |
) |
|---|
| 353 |
|
|---|
| 354 |
) |
|---|
| 355 |
|
|---|
| 356 |
$(SECTION3 $(LNAME2 inheriting-ctors, Inheriting Constructors), |
|---|
| 357 |
|
|---|
| 358 |
$(P $(LINK2 $(NDOCS)2008/n2540.html, N2540): TBD |
|---|
| 359 |
) |
|---|
| 360 |
|
|---|
| 361 |
) |
|---|
| 362 |
|
|---|
| 363 |
$(SECTION3 $(LNAME2 sequence-points, A finer-grained alternative to sequence points), |
|---|
| 364 |
|
|---|
| 365 |
$(P $(LINK2 $(NDOCS)2007/n2239.htm, N2239): TBD |
|---|
| 366 |
) |
|---|
| 367 |
|
|---|
| 368 |
) |
|---|
| 369 |
|
|---|
| 370 |
$(SECTION3 $(LNAME2 lambda, (monomorphic) Lambda expressions and closures for C++), |
|---|
| 371 |
|
|---|
| 372 |
$(P $(LINK2 $(NDOCS)2008/n2550.pdf, N2550): |
|---|
| 373 |
D has $(LINK2 expression.html#FunctionLiteral, lambda expressions) and |
|---|
| 374 |
$(LINK2 function.html#closures, closures). |
|---|
| 375 |
) |
|---|
| 376 |
|
|---|
| 377 |
) |
|---|
| 378 |
|
|---|
| 379 |
$(SECTION3 $(LNAME2 __func__, Proposed addition of __func__ predefined identifier from C99), |
|---|
| 380 |
|
|---|
| 381 |
$(P $(LINK2 $(NDOCS)2007/n2340.html, N2340): TBD |
|---|
| 382 |
) |
|---|
| 383 |
|
|---|
| 384 |
) |
|---|
| 385 |
|
|---|
| 386 |
$(SECTION3 $(LNAME2 atomic, Atomic operations with multi-threaded environments), |
|---|
| 387 |
|
|---|
| 388 |
$(P $(LINK2 $(NDOCS)2007/n2427.html, N2427): TBD |
|---|
| 389 |
) |
|---|
| 390 |
|
|---|
| 391 |
) |
|---|
| 392 |
|
|---|
| 393 |
$(SECTION3 $(LNAME2 concurrency, Sequencing and the concurrency memory model), |
|---|
| 394 |
|
|---|
| 395 |
$(P $(LINK2 $(NDOCS)2007/n2429.htm, N2429): TBD |
|---|
| 396 |
) |
|---|
| 397 |
|
|---|
| 398 |
) |
|---|
| 399 |
|
|---|
| 400 |
$(SECTION3 $(LNAME2 raw-strings, Raw String Literals), |
|---|
| 401 |
|
|---|
| 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. |
|---|
| 405 |
) |
|---|
| 406 |
|
|---|
| 407 |
) |
|---|
| 408 |
|
|---|
| 409 |
$(SECTION3 $(LNAME2 pod, PODs unstrung), |
|---|
| 410 |
|
|---|
| 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. |
|---|
| 415 |
) |
|---|
| 416 |
|
|---|
| 417 |
) |
|---|
| 418 |
|
|---|
| 419 |
$(SECTION3 $(LNAME2 exceptions, Propagating exceptions when joining threads), |
|---|
| 420 |
|
|---|
| 421 |
$(P $(LINK2 $(NDOCS)2007/n2179.html, N2179): TBD |
|---|
| 422 |
) |
|---|
| 423 |
|
|---|
| 424 |
) |
|---|
| 425 |
|
|---|
| 426 |
$(SECTION3 $(LNAME2 decltype, Decltype), |
|---|
| 427 |
|
|---|
| 428 |
$(P $(LINK2 $(NDOCS)2007/n2343.pdf, N2343): |
|---|
| 429 |
The equivalent D construct is $(LINK2 declaration.html#typeof, typeof). |
|---|
| 430 |
) |
|---|
| 431 |
|
|---|
| 432 |
) |
|---|
| 433 |
|
|---|
| 434 |
$(SECTION3 $(LNAME2 sizeof, Extending sizeof), |
|---|
| 435 |
|
|---|
| 436 |
$(P $(LINK2 $(NDOCS)2007/n2253.html, N2253): |
|---|
| 437 |
Using $(LINK2 property.html#sizeof, sizeof) without a $(I this) object: |
|---|
| 438 |
--- |
|---|
| 439 |
struct S { |
|---|
| 440 |
int a; |
|---|
| 441 |
static int foo() { |
|---|
| 442 |
return a.sizeof; |
|---|
| 443 |
} |
|---|
| 444 |
} |
|---|
| 445 |
|
|---|
| 446 |
void test() { |
|---|
| 447 |
int x = S.a.sizeof; |
|---|
| 448 |
} |
|---|
| 449 |
--- |
|---|
| 450 |
works correctly in D. |
|---|
| 451 |
) |
|---|
| 452 |
|
|---|
| 453 |
) |
|---|
| 454 |
|
|---|
| 455 |
$(SECTION3 $(LNAME2 utf8-literals, UTF-8 Literals), |
|---|
| 456 |
|
|---|
| 457 |
$(P $(LINK2 $(NDOCS)2007/n2442.html, N2442): |
|---|
| 458 |
$(LINK2 lex.html#StringLiteral, Char string literals) |
|---|
| 459 |
are in UTF-8 format. |
|---|
| 460 |
) |
|---|
| 461 |
|
|---|
| 462 |
) |
|---|
| 463 |
|
|---|
| 464 |
$(SECTION3 $(LNAME2 ucs-in-literals, Universal Character Names in Literals), |
|---|
| 465 |
|
|---|
| 466 |
$(P $(LINK2 $(NDOCS)2007/n2170.html, N2170): |
|---|
| 467 |
All Unicode characters are allowed in |
|---|
| 468 |
$(LINK2 lex.html#StringLiteral, string literals). |
|---|
| 469 |
Surrogate pair halves are not allowed unless hex literal notation |
|---|
| 470 |
is used. |
|---|
| 471 |
) |
|---|
| 472 |
|
|---|
| 473 |
) |
|---|
| 474 |
|
|---|
| 475 |
$(SECTION3 $(LNAME2 defaulted, Defaulted and Deleted Functions), |
|---|
| 476 |
|
|---|
| 477 |
$(P $(LINK2 $(NDOCS)/2007/n2326.html#delete, N2326): |
|---|
| 478 |
D alows individual functions to be marked as $(LINK2 attribute.html#disable, disabled). |
|---|
| 479 |
) |
|---|
| 480 |
|
|---|
| 481 |
) |
|---|
| 482 |
|
|---|
| 483 |
|
|---|
| 484 |
$(SECTION3 $(LNAME2 unions, Unrestricted Unions), |
|---|
| 485 |
|
|---|
| 486 |
$(P $(LINK2 $(NDOCS)2008/n2544.pdf, N2544): TBD |
|---|
| 487 |
) |
|---|
| 488 |
|
|---|
| 489 |
) |
|---|
| 490 |
|
|---|
| 491 |
$(SECTION3 $(LNAME2 library, A Multi-threading Library for Standard C++), |
|---|
| 492 |
|
|---|
| 493 |
$(P $(LINK2 $(NDOCS)2007/n2447.html, N2447): TBD |
|---|
| 494 |
) |
|---|
| 495 |
|
|---|
| 496 |
) |
|---|
| 497 |
|
|---|
| 498 |
$(SECTION3 $(LNAME2 abandoning, Abandoning a Process), |
|---|
| 499 |
|
|---|
| 500 |
$(P $(LINK2 $(NDOCS)2007/n2440.html, N2440): TBD |
|---|
| 501 |
) |
|---|
| 502 |
|
|---|
| 503 |
) |
|---|
| 504 |
|
|---|
| 505 |
$(SECTION3 $(LNAME2 return-types, New function declaration syntax for deduced return types), |
|---|
| 506 |
|
|---|
| 507 |
$(P $(LINK2 $(NDOCS)2007/n2445.html, N2445): TBD |
|---|
| 508 |
) |
|---|
| 509 |
|
|---|
| 510 |
) |
|---|
| 511 |
|
|---|
| 512 |
$(SECTION3 $(LNAME2 atomic-signals, Allow atomics use in signal handlers), |
|---|
| 513 |
|
|---|
| 514 |
$(P $(LINK2 $(NDOCS)2008/n2547.htm, N2547): TBD |
|---|
| 515 |
) |
|---|
| 516 |
|
|---|
| 517 |
) |
|---|
| 518 |
|
|---|
| 519 |
$(SECTION3 $(LNAME2 local-classes, Making Local Classes more Useful), |
|---|
| 520 |
|
|---|
| 521 |
$(P $(LINK2 $(NDOCS)2007/n2402.pdf, N2402): |
|---|
| 522 |
D has no restrictions on using local classes as template |
|---|
| 523 |
parameters. |
|---|
| 524 |
) |
|---|
| 525 |
|
|---|
| 526 |
) |
|---|
| 527 |
|
|---|
| 528 |
$(SECTION3 $(LNAME2 initializer-lists, Initializer lists), |
|---|
| 529 |
|
|---|
| 530 |
$(P $(LINK2 $(NDOCS)2008/n2531.pdf, N2531): |
|---|
| 531 |
D has |
|---|
| 532 |
$(LINK2 struct.html#StructLiteral, struct literals), |
|---|
| 533 |
$(LINK2 expression.html#ArrayLiteral, array literals), |
|---|
| 534 |
and $(LINK2 expression.html#AssocArrayLiteral, associative array literals). |
|---|
| 535 |
) |
|---|
| 536 |
|
|---|
| 537 |
) |
|---|
| 538 |
|
|---|
| 539 |
$(SECTION3 $(LNAME2 thread-local-storage, Thread-Local Storage), |
|---|
| 540 |
|
|---|
| 541 |
$(P $(LINK2 $(NDOCS)2007/n2280.html, N2280): |
|---|
| 542 |
Thread-local storage is the default for statics and globals |
|---|
| 543 |
in D. Thread-global storage is done by using the |
|---|
| 544 |
$(LINK2 migrate-to-shared.html, $(B shared)) |
|---|
| 545 |
storage class. |
|---|
| 546 |
) |
|---|
| 547 |
|
|---|
| 548 |
) |
|---|
| 549 |
|
|---|
| 550 |
$(SECTION3 $(LNAME2 member-initializers, Member Initializers), |
|---|
| 551 |
|
|---|
| 552 |
$(P $(LINK2 $(NDOCS)2007/n2426.htm, N2426): |
|---|
| 553 |
D has |
|---|
| 554 |
$(LINK2 class.html#class-default-initializer, member initializers), |
|---|
| 555 |
which are called $(I default initializers). |
|---|
| 556 |
) |
|---|
| 557 |
|
|---|
| 558 |
) |
|---|
| 559 |
|
|---|
| 560 |
$(SECTION3 $(LNAME2 concepts, Concepts (unified proposal)), |
|---|
| 561 |
|
|---|
| 562 |
$(P $(LINK2 $(NDOCS)2006/n2081.pdf, N2081): |
|---|
| 563 |
The D equivalent of C++ concepts are $(LINK2 concepts.html, constraints). |
|---|
| 564 |
(As of $(LINK2 http://www.ddj.com/cpp/218600111, July 2009), |
|---|
| 565 |
Concepts have been dropped from C++0x.) |
|---|
| 566 |
) |
|---|
| 567 |
|
|---|
| 568 |
$(TABLE2 Concepts and Constraints, |
|---|
| 569 |
|
|---|
| 570 |
$(TR |
|---|
| 571 |
$(TH Description) |
|---|
| 572 |
$(TH D Constraints) |
|---|
| 573 |
$(TH C++0x Concepts) |
|---|
| 574 |
) |
|---|
| 575 |
|
|---|
| 576 |
$(TR |
|---|
| 577 |
$(TD Overloading based on concepts/constraints) |
|---|
| 578 |
$(TD Yes) |
|---|
| 579 |
$(TD Yes) |
|---|
| 580 |
) |
|---|
| 581 |
|
|---|
| 582 |
$(TR |
|---|
| 583 |
$(TD Concepts/constraints on template type parameters) |
|---|
| 584 |
$(TD Yes) |
|---|
| 585 |
$(TD Yes) |
|---|
| 586 |
) |
|---|
| 587 |
|
|---|
| 588 |
$(TR |
|---|
| 589 |
$(TD Concepts/constraints on template value parameters) |
|---|
| 590 |
$(TD Yes) |
|---|
| 591 |
$(TD No) |
|---|
| 592 |
) |
|---|
| 593 |
|
|---|
| 594 |
$(TR |
|---|
| 595 |
$(TD Concepts/constraints on template template/alias parameters) |
|---|
| 596 |
$(TD Yes) |
|---|
| 597 |
$(TD No) |
|---|
| 598 |
) |
|---|
| 599 |
|
|---|
| 600 |
$(TR |
|---|
| 601 |
$(TD Composition and refinement of concepts/constraints) |
|---|
| 602 |
$(TD Yes) |
|---|
| 603 |
$(TD Yes) |
|---|
| 604 |
) |
|---|
| 605 |
|
|---|
| 606 |
$(TR |
|---|
| 607 |
$(TD Multi-type concepts/constraints) |
|---|
| 608 |
$(TD Yes) |
|---|
| 609 |
$(TD Yes) |
|---|
| 610 |
) |
|---|
| 611 |
|
|---|
| 612 |
$(TR |
|---|
| 613 |
$(TD Expression of concepts/constraints) |
|---|
| 614 |
$(TD Done with compile time expressions) |
|---|
| 615 |
$(TD Done by enumeration of function signatures) |
|---|
| 616 |
) |
|---|
| 617 |
|
|---|
| 618 |
$(TR |
|---|
| 619 |
$(TD Axioms) |
|---|
| 620 |
$(TD Yes (as static asserts and function preconditions)) |
|---|
| 621 |
$(TD Yes) |
|---|
| 622 |
) |
|---|
| 623 |
|
|---|
| 624 |
$(TR |
|---|
| 625 |
$(TD new keywords) |
|---|
| 626 |
$(TD No) |
|---|
| 627 |
$(TD Yes: where, concept, concept_map, axiom, late_check) |
|---|
| 628 |
) |
|---|
| 629 |
|
|---|
| 630 |
$(TR |
|---|
| 631 |
$(TD Semantic analysis of template bodies) |
|---|
| 632 |
$(TD Lazy (done at instantiation time)) |
|---|
| 633 |
$(TD Eager (done at definition time)) |
|---|
| 634 |
) |
|---|
| 635 |
|
|---|
| 636 |
$(TR |
|---|
| 637 |
$(TD Template body checked against concept/constraint) |
|---|
| 638 |
$(TD No) |
|---|
| 639 |
$(TD Yes) |
|---|
| 640 |
) |
|---|
| 641 |
|
|---|
| 642 |
$(TR |
|---|
| 643 |
$(TD Concept maps) |
|---|
| 644 |
$(TD No (but could be done with proxy objects)) |
|---|
| 645 |
$(TD Yes) |
|---|
| 646 |
) |
|---|
| 647 |
|
|---|
| 648 |
$(TR |
|---|
| 649 |
$(TD All operations on constrained types must be specified in |
|---|
| 650 |
concept/constraint) |
|---|
| 651 |
$(TD No) |
|---|
| 652 |
$(TD Yes) |
|---|
| 653 |
) |
|---|
| 654 |
|
|---|
| 655 |
$(TR |
|---|
| 656 |
$(TD Complexity) |
|---|
| 657 |
$(TD $(CODE if (expression)) added to template grammar) |
|---|
| 658 |
$(TD quite a bit of new grammar and semantics added) |
|---|
| 659 |
) |
|---|
| 660 |
|
|---|
| 661 |
|
|---|
| 662 |
) |
|---|
| 663 |
|
|---|
| 664 |
) |
|---|
| 665 |
|
|---|
| 666 |
$(SECTION3 $(LNAME2 for-loop, Proposal for new for-loop), |
|---|
| 667 |
|
|---|
| 668 |
$(P $(LINK2 $(NDOCS)2007/n2394.html, N2394): |
|---|
| 669 |
This is equivalent to the D |
|---|
| 670 |
$(LINK2 statement.html#ForeachRangeStatement, $(I ForeachRangeStatement)). |
|---|
| 671 |
) |
|---|
| 672 |
|
|---|
| 673 |
) |
|---|
| 674 |
|
|---|
| 675 |
$(SECTION3 $(LNAME2 general-attributes, General Attributes for C++), |
|---|
| 676 |
|
|---|
| 677 |
$(P $(LINK2 $(NDOCS)2007/n2418.pdf, N2418): |
|---|
| 678 |
Vendor specific attributes can be applied to statements |
|---|
| 679 |
and declarations with |
|---|
| 680 |
$(LINK2 pragma.html, pragmas). |
|---|
| 681 |
) |
|---|
| 682 |
|
|---|
| 683 |
) |
|---|
| 684 |
|
|---|
| 685 |
$(SECTION3 $(LNAME2 extensible-literals, Extensible Literals), |
|---|
| 686 |
|
|---|
| 687 |
$(P $(LINK2 $(NDOCS)2007/n2378.pdf, N2378): |
|---|
| 688 |
D does not have user extensible literals. |
|---|
| 689 |
) |
|---|
| 690 |
|
|---|
| 691 |
) |
|---|
| 692 |
|
|---|
| 693 |
$(SECTION3 $(LNAME2 dynamic-concurrency, Dynamic initialization and concurrency), |
|---|
| 694 |
|
|---|
| 695 |
$(P $(LINK2 $(NDOCS)2008/n2513.html, N2513): TBD |
|---|
| 696 |
) |
|---|
| 697 |
|
|---|
| 698 |
) |
|---|
| 699 |
|
|---|
| 700 |
$(SECTION3 $(LNAME2 garbage-collection, Minimal Support for Garbage Collection and Reachability-Based Leak Detection), |
|---|
| 701 |
|
|---|
| 702 |
$(P $(LINK2 $(NDOCS)2008/n2527.html, N2527): |
|---|
| 703 |
Garbage collection is optional in C++0x, |
|---|
| 704 |
D $(LINK2 garbage.html, requires it). |
|---|
| 705 |
The problem with an optional garbage collector is that in order |
|---|
| 706 |
to write general purpose libraries, one must assume that there is |
|---|
| 707 |
no garbage collector, therefore none of the productivity enhancing |
|---|
| 708 |
advantages of it are available. |
|---|
| 709 |
) |
|---|
| 710 |
|
|---|
| 711 |
) |
|---|
| 712 |
|
|---|
| 713 |
$(SECTION3 $(LNAME2 forward-enums, Forward declaration of enumerations), |
|---|
| 714 |
|
|---|
| 715 |
$(P $(LINK2 $(NDOCS)2008/n2499.pdf, N2499): |
|---|
| 716 |
Forward declarations are not necessary in D, as all declarations |
|---|
| 717 |
are resolved essentially in parallel. |
|---|
| 718 |
Incomplete $(LINK2 enum.html, enum) types, however, are possible: |
|---|
| 719 |
) |
|---|
| 720 |
--- |
|---|
| 721 |
enum E : int; |
|---|
| 722 |
--- |
|---|
| 723 |
$(P where the member values are hidden from the user. |
|---|
| 724 |
) |
|---|
| 725 |
|
|---|
| 726 |
) |
|---|
| 727 |
|
|---|
| 728 |
) |
|---|
| 729 |
|
|---|
| 730 |
Macros: |
|---|
| 731 |
TITLE=D and C++0x |
|---|
| 732 |
WIKI=Cpp0x |
|---|
| 733 |
DOLLAR=$ |
|---|
| 734 |
NDOCS=http://www.open-std.org/jtc1/sc22/wg21/docs/papers/ |
|---|
| 735 |
FOO= |
|---|