Approval Detailed Specification Design Investigation.

56
The future of C++ Herb Sutter Partner Program Manager 2-306

Transcript of Approval Detailed Specification Design Investigation.

Page 1: Approval Detailed Specification Design Investigation.

The future of C++

Herb SutterPartner Program Manager2-306

Page 2: Approval Detailed Specification Design Investigation.

The future of C++

Herb SutterPartner Program Manager2-306

Page 3: Approval Detailed Specification Design Investigation.

C++ at ISO: ISO C++ UpdateC++ at MSFT: Visual C++ Update

Agenda

Page 4: Approval Detailed Specification Design Investigation.

ISO C++ Update

Page 5: Approval Detailed Specification Design Investigation.

Library Evolution WG

Library WG

WG21 and {concurrency, parallelism}

WG21 – Full Committee

Evolution WG

Core WG

SG5Tx. Memory

SG2Modules

SG1Concurrency

SG6Numerics

SG4Networking

SG3Filesystem

SG7Reflection

SG8Concepts

SG9Ranges

SG10Feature Test

Approval

Detailed Specification

Design

InvestigationSG11

DatabasesSG12

U. Behavior

Page 6: Approval Detailed Specification Design Investigation.

Thanks to all the volunteers!

ISO C++ committee (WG21) attendance

Sep 2008

Mar 2009

Jul 2009

Oct 2009

Mar 2010

Aug 2010

Nov 2010

Mar 2011

Aug 2011

Feb 2012

Oct 2012

Apr 2013

0

20

40

60

80

100

Meeting size (#attendees)

CompletedC++11

Page 7: Approval Detailed Specification Design Investigation.

Thanks to all the volunteers!

ISO C++ committee (WG21) attendance

Sep 2008

Mar 2009

Jul 2009

Oct 2009

Mar 2010

Aug 2010

Nov 2010

Mar 2011

Aug 2011

Feb 2012

Oct 2012

Apr 2013

0

20

40

60

80

100

Meeting size (#attendees)

CompletedC++11

CompletedC++14

CD

MilestoneIn April 2013, for the first time C++14’s feature set

is known: C++14 is feature-complete!

Now in primary international comment

ballot

Page 8: Approval Detailed Specification Design Investigation.

You arehere

ISO C++ timeline: The “C++14 wave”

98 99 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18

C++98(major)

Library TR1 (aka TS) Performance TR

C++03(TC, bug fixes only)

C++11(major)

C++17(major)

C++14(minor)

FileSysTSNetTS1Concepts

TS

14

2014 cadenceThis ISO C++ revision

cycle: faster, more predictable

Less monolithic: Delivering concurrent

and decoupled library & language extensions

Page 9: Approval Detailed Specification Design Investigation.

“C++14 completes C++11”

VC++ target: C++14

We will implement all of C++11 and 14, but some

high-value ’14 features should come before others from ’11

Page 10: Approval Detailed Specification Design Investigation.

Visual C++ Roadmap

Page 11: Approval Detailed Specification Design Investigation.

As each new ISO C++ language feature implementation reaches the stream’s bar, it will appear in the stream’s next planned drop — CTP or (usually major) release

Two streams: Release + CTPVisual Studio

Release StreamOut of Band (OOB)

CTP Stream

Ship vehicleNormally: Major release on new

cadenceMaybe: Some might appear in an

UpdateSeparate CTP drop

Batch compiler support Yes Yes — SxS

Use in standard library

Yes (but no breaking changes in Updates) Maybe

Intellisense support Yes NoStatic analysis support Yes Maybe

Go-live license Yes No

Page 12: Approval Detailed Specification Design Investigation.

As each new ISO C++ language feature implementation reaches the stream’s bar, it will appear in the stream’s next planned drop — CTP or (usually major) release

Two streams: Release + CTPVisual Studio

Release StreamOut of Band (OOB)

CTP Stream

Ship vehicleNormally: Major release on new

cadenceMaybe: Some might appear in an

UpdateSeparate CTP drop

Batch compiler support Yes Yes — SxS

Use in standard library

Yes (but no breaking changes in Updates) Maybe

Intellisense support Yes NoStatic analysis support Yes Maybe

Go-live license Yes No

2013 RoadmapVS 2013 Preview today

VS 2013 RTM later this yearCTP following VS 2013 RTM

Page 13: Approval Detailed Specification Design Investigation.

Continue to deliver C++11More batches coming in 1H13

Continue to investin platform supportWindows Store apps• Continue to bring C++/CX forward to solve

problems like asynchrony• Continue to make extensions/rewrite less

intrusive to existing C++ code• Example of both: await

Phone apps• See also: Writing C++ components on

Windows 8 & Windows Phone 8Azure (e.g., Casablanca)

VC++ next steps

from Nov 2012

Page 14: Approval Detailed Specification Design Investigation.

Visual C++ 2013 Preview

Page 15: Approval Detailed Specification Design Investigation.

Core languageEverything in Nov 2012 CTP, with IDE/debugger/static analysis support• explicit conversion operators• Raw string literals• Function template default arguments• Delegating constructors• Uniform initialization and initializer_lists• Variadic templates

Standard libraryStandard library support for the above, incl. vector<int>{ 1, 2, 3, 4 }Faster compiles & reduced memory compiling stdlib (variadics help here)Some Draft C++14 improvements (approved in Portland and Bristol):• make_unique, cbegin/cend/etc., simplified functors (e.g., greater<>)

From CTP quality to RTM quality

Available today: VC++ 2013 Preview

Page 16: Approval Detailed Specification Design Investigation.

Conformance roadmap: The road to C++14VC++ 2013

Previewtoday

Explicit conversion operators

Raw string literals

Function template default arguments

Delegating constructors

Uniform init & initializer_lists

Variadic templates

C++14 libs: cbegin/ greater<>/make_uni

que

Page 17: Approval Detailed Specification Design Investigation.

Visual C++ 2013 RTM

Page 18: Approval Detailed Specification Design Investigation.

class widget { int a = 42; string b = “xyzzy”; vector<int> c = { 1, 2, 3, 4 };public: widget() { } // 42 xyzzy 1 2 3 4 explicit widget(int val) : a{val} { } // valxyzzy 1 2 3 4 widget(int i, int j) : c{i, i, i, i, j, j} { } // 42 xyzzy i i i i j j};

“… to increase maintainability, reduce the risk of subtle errors in complex program code, and to make the use of initializers more consistent.”

— N2628, Michael Spertus and Bill

Seymour

Non-static data member initializers

Page 19: Approval Detailed Specification Design Investigation.

Why is =default better than writing it yourself?• =default is shorter and less redundant.• Default implementations can be more efficient than manual

implementations.• Default implementations can be “trivial,” so preserve POD-ness.• Provides an easy way to get an otherwise implicitly-suppressed generated

function.

Exampleclass value { // … possibly lots of members …public: value& operator=( const value& ); // provide custom value( const value& ); // copying behavior value() = default; // unsuppress default constructor w/o rewriting it};Note: Not initially on move construction/assignment• Part of another feature: Will be added when we support implicit move

generation

“The definition form ‘=default;’ indicates that the function’s default definition should be used.”

— N2210, Lawrence Crowl

= default

Page 20: Approval Detailed Specification Design Investigation.

Example: Disabling copying, better diagnosticclass type {public: type( const type& ) = delete; type& operator=( const type& ) = delete; type() = default; // restore suppressed default constructor};Example: Eliminating undesirable conversions/overloadsvoid bar( long long ); // accept long long…void bar( long ) = delete; // … but nothing elseclass custom_regex_iterator { // stores a pointer to its regexpublic: // … custom_regex_iterator( const regex& ); // lvalues only please custom_regex_iterator( const regex&& ) = delete; // no rvalues need apply};

“… use of default language facilities [and problematic conversions] can be made an error by deleting the definition… [This] achieves the goal of making a bad overload visible.”

— N2210, Lawrence Crowl

= delete

Page 21: Approval Detailed Specification Design Investigation.

C++98 codetemplate<class T> struct Vec { typedef vector<T, MyAlloc<T>> type; };Vec<int>::type v; // sample usagetemplate<class T> void f( typename Vec<T>::type& ); // non-deduciblef<int>( v );C++11 codetemplate<class T> using Vec = vector<T, MyAlloc<T>>;Vec<int> v; // sample usagetemplate<class T> void f( Vec<T>& ); // deduciblef( v );Draft C++14 (approved in Bristol)Standard library type aliases – thanks, Walter Brown! Examples:• remove_reference_t<T> vs. typename remove_reference<T>::type• make_unsigned_t<T> vs. typename make_unsigned<T>::type

“… it will not be possible to call the function foo below without explicitly specifying template arguments. … Also, the syntax is somewhat ugly.”

— N1449, Gabriel Dos Reis and Mat Marcus

using aliases

Page 22: Approval Detailed Specification Design Investigation.

Conformance roadmap: The road to C++14VC++ 2013

Previewtoday

VC++ 2013 RTMlater this year

Explicit conversion operators

Non-static data member initializers

Raw string literals = default

Function template default arguments = delete

Delegating constructors

“using” aliasesC++14 libs: type

aliasesUniform init & initializer_lists

Variadic templates

C++14 libs: cbegin/ greater<>/make_uni

que

Page 23: Approval Detailed Specification Design Investigation.

And now for something completely different…

Page 24: Approval Detailed Specification Design Investigation.

Adding a few “tactical” C99/C11 featuresvoid func() { _Bool b = whatever(); // _Bool can be 0 or 1 if( b ) { … } int val = 42; // variable declarations within blocks // …}Compound literals: “Cast an initializer to a type”struct mystruct { char tag[3]; int value; };struct mystruct x;x = (struct mystruct) { ‘A’, ‘B’, 0, 42*func() };

Note: not an intent to conform to C99/C11

May not have full Intellisense

C99 variable decls, _Bool, compound literals

Page 25: Approval Detailed Specification Design Investigation.

Initialize elements of an aggregate (array, struct, union) in any orderunion { int a; short b; } uab = { .b = 13 };struct mystruct { int m1; int m2; int m3;};struct mystruct x = { .m1 = 42, .m3 = 84 }; // .m2==0int arr[][2] = { [0][0]=1, [1][1]=1 }; // 22, other values == 0

Note: not an intent to conform to C99/C11

May not have full Intellisense

C99 designated initializers

Page 26: Approval Detailed Specification Design Investigation.

Example: Enables FFmpeg (ffmpeg.org)

Page 27: Approval Detailed Specification Design Investigation.

Conformance roadmap: The road to C++14VC++ 2013

Previewtoday

VC++ 2013 RTMlater this year

Explicit conversion operators

Non-static data member initializers

Raw string literals = default

Function template default arguments = delete

Delegating constructors

“using” aliasesC++14 libs: type

aliasesUniform init & initializer_lists

C99 variable declsC99 _Bool

Variadic templates C99 compound literals

C++14 libs: cbegin/ greater<>/make_uni

queC99 designated

initializers

Page 28: Approval Detailed Specification Design Investigation.

Post-RTM: What we’re implementing now (some in next VC++ OOB CTP)

Page 29: Approval Detailed Specification Design Investigation.

Minor tweaks that can be helpful#define ENTER_FUNC std::cout << “Entering “ << __func__ << std::endl;void f() { ENTER_FUNC; // print f’s name}And eliminate surprising “you can’t do that”sclass widget { int member; static void f() { size_t s = sizeof(member); // ok in C++11 }};size_t s = sizeof(widget::member); // ok in C++11

__func__ is not quite the same as in C

Now sizeof can be applied to a member without needing to fake up an object

Misc.: __func__, extended sizeof

Page 30: Approval Detailed Specification Design Investigation.

Consider this codeclass myclass { vector<widget> vw; string s;};myclass factory();auto instance = factory();

C++98: OK, but inefficient• myclass is implicitly memberwise copyable

C++11: OK, fast by default• myclass is implicitly memberwise copyable and movable

Note: Enables =default for move construction and assignment

a.k.a. “rvalue references v3”

— Stephan T. Lavavej

Implicit move generation

Page 31: Approval Detailed Specification Design Investigation.

If you want to take &&, just say so on the parameter…class widget { };void f( const widget& ); // w is a const&void g( widget& w ); // w is a & – must be lvaluevoid h( widget&& w ); // w is a && – must be rvalueh( widget() ); // ok for && (note: temporary widget)… but what about the “invisible” implicit this?class widget { void f() const; // *this is const (implicitly ref-like) void g() &; // *this is an lvalue void h() &&; // *this is an rvalue};widget().h(); // ok for && (note: temporary widget)

Decorating “implicit this” with & and &&, just like we already do with const and volatile

Example: Overload on & vs. && so in the latter you can “move your guts out”

Ref-qualifiers: & and && for *this

Page 32: Approval Detailed Specification Design Investigation.

C++11[=]() -> some_type { return foo() * 42; } // ok[=] { return foo() * 42; } // ok, deduces “-> some_type”Draft C++14 (approved in Bristol)(Already supported in Visual Studio 2012)[=] { // ok, deduces “-> some_type” while( something() ) { if( expr ) { return foo() * 42; // with arbitrary control flow } } return bar.baz(84); // & multiple returns} // (types must be the same)

In the “quit repeating repeating yourself” category…

C++14 lambda return type deduction

Page 33: Approval Detailed Specification Design Investigation.

C++11, explicitly named return typesome_type f() { return foo() * 42; } // okauto f() -> some_type { return foo() * 42; } // okDraft C++14, deduced return type (approved in Bristol)auto f() { return foo() * 42; } // ok, deduces “-> some_type”auto g() { // ok, deduces “-> some_type” while( something() ) { if( expr ) { return foo() * 42; // with arbitrary control flow } } return bar.baz(84);// & multiple returns} // (types must be the same)

What’s good for the [goose]{} is good for the gander();

Someone will ask: “Can it be recursive?”

Yes. As long as a return precedes the recursive call.

C++14 function return type deduction

Page 34: Approval Detailed Specification Design Investigation.

C++11: no move capturevoid sink( unique_ptr<widget> upw ) { pool.run([??]{ use(*upw); }); // can’t do this pool.run( bind([](unique_ptr<widget>& w){ use(*w); }, move(upw)) );} // this is an important & — extremely nonobvious

C++14: (not just) move capture (approved in Bristol)void sink( unique_ptr<widget> upw ) { pool.run([w = move(upw)]{ use(*w); });}More than move: Renaming + arbitrary extra stateint x = 4;int z = [&r = x, y = x+1] { r += 2; // ::x = 6; “R is for Renamed Ref”

return y+2; // return 7 to initialize z} ( );

Getting C++ out of a “bind”…

C++14 Generalized lambda capture

Page 35: Approval Detailed Specification Design Investigation.

C++11for_each( begin(v), end(v), [](const decltype(*begin(v))& x) { cout << x; } );sort( begin(w), end(w), [](const shared_ptr<some_type>& a,

const shared_ptr<some_type>& b) { return *a<*b; } );auto size = [](const unordered_map<wstring, vector<string>>& m)

{ return m.size(); };Draft C++14: Deduce C++11 cases + reuse with different types (approved in Bristol)for_each( cbegin(v), cend(v), [](const auto& x) { cout << x; } );sort( begin(w), end(w), [](const auto& a, const auto& b){ return *a<*b; });auto size = [](const auto& m) { return m.size(); };

// bonus: now works with any container that supports .size()

Probably the #1 requested C++14 feature

Someone will ask: “Can two autos in one signature deduce differently?”

Yes. And if you change sort to lower_bound, that’s what you want.

C++14 generic lambdas

Page 36: Approval Detailed Specification Design Investigation.

Conformance roadmap: The road to C++14VC++ 2013

Previewtoday

VC++ 2013 RTMlater this year

Explicit conversion operators

Non-static data member initializers

__func__Extended sizeof

Raw string literals = default Implicit move generation

Function template default arguments = delete Ref-qualifiers:

& and && for *this

Delegating constructors

“using” aliasesC++14 libs: type

aliasesC++14 generalized

lambda capture

Uniform init & initializer_lists

C99 variable declsC99 _Bool

C++14 auto function return type

deduction

Variadic templates C99 compound literals

C++14 generic lambdas

C++14 libs: cbegin/ greater<>/make_uni

queC99 designated

initializers

Post-RTM OOB CTPWhat we’re currently implementing, roughly in order… some subset in

CTP

Page 37: Approval Detailed Specification Design Investigation.

Conformance roadmap: The road to C++14VC++ 2013

Previewtoday

VC++ 2013 RTMlater this year

Explicit conversion operators

Non-static data member initializers

__func__Extended sizeof

Thread-safe function local static

init

Raw string literals = default Implicit move generation User-defined literals

Function template default arguments = delete Ref-qualifiers:

& and && for *this noexcept

Delegating constructors

“using” aliasesC++14 libs: type

aliasesC++14 generalized

lambda capturealignofalignas

Uniform init & initializer_lists

C99 variable declsC99 _Bool

C++14 auto function return type

deductionconstexpr (except

ctors / literal types)

Variadic templates C99 compound literals

C++14 generic lambdas

C++14 decltype(auto)

C++14 libs: cbegin/ greater<>/make_uni

queC99 designated

initializersC++14 libs: std::

user-defined literals

Post-RTM OOB CTPWhat we’re currently implementing, roughly in order… some subset in

CTP

Page 38: Approval Detailed Specification Design Investigation.

The road to C++14: What’s left beyond VC++ 2013 and the next CTP?

Page 39: Approval Detailed Specification Design Investigation.

Conformance roadmap: The road to C++14VC++ 2013

Previewtoday

VC++ 2013 RTMlater this year

Explicit conversion operators

Non-static data member initializers

__func__Extended sizeof

Thread-safe function local static

initUnrestricted

unions Attributes

Raw string literals = default Implicit move generation User-defined literals

Universal character

names in literalsthread_local

Function template default arguments = delete Ref-qualifiers:

& and && for *this noexcept Expression SFINAE

Delegating constructors

“using” aliasesC++14 libs: type

aliasesC++14 generalized

lambda capturealignofalignas

Inheriting constructors

Uniform init & initializer_lists

C99 variable declsC99 _Bool

C++14 auto function return type

deductionconstexpr (except

ctors / literal types)constexpr

(literal types)

Variadic templates C99 compound literals

C++14 generic lambdas

C++14 decltype(auto)

Inline namespaces

C++14 libs: cbegin/ greater<>/make_uni

queC99 designated

initializersC++14 libs: std::

user-defined literalschar16_t, char32_t

Post-RTM OOB CTPWhat we’re currently implementing, roughly in order… some subset in

CTP

PlannedWhat’s next for full conformance

Page 40: Approval Detailed Specification Design Investigation.

Conformance roadmap: The road to C++14VC++ 2013

Previewtoday

VC++ 2013 RTMlater this year

Explicit conversion operators

Non-static data member initializers

__func__Extended sizeof

Thread-safe function local static

initUnrestricted

unions Attributes

Raw string literals = default Implicit move generation User-defined literals

Universal character

names in literalsthread_local

Function template default arguments = delete Ref-qualifiers:

& and && for *this noexcept Expression SFINAE

C++11 preprocessor

(incl. C++98 & C11)

Delegating constructors

“using” aliasesC++14 libs: type

aliasesC++14 generalized

lambda capturealignofalignas

Inheriting constructors

C++98 two-phase lookup

Uniform init & initializer_lists

C99 variable declsC99 _Bool

C++14 auto function return type

deductionconstexpr (except

ctors / literal types)constexpr

(literal types)

Variadic templates C99 compound literals

C++14 generic lambdas

C++14 decltype(auto)

Inline namespaces

C++14 libs: cbegin/ greater<>/make_uni

queC99 designated

initializersC++14 libs: std::

user-defined literalschar16_t, char32_t

Post-RTM OOB CTPWhat we’re currently implementing, roughly in order… some subset in

CTP

PlannedWhat’s next for full conformance

Page 41: Approval Detailed Specification Design Investigation.

Conformance roadmap: The road to C++14VC++ 2013

Previewtoday

VC++ 2013 RTMlater this year

Explicit conversion operators

Non-static data member initializers

__func__Extended sizeof

Thread-safe function local static

initUnrestricted

unions Attributes

Raw string literals = default Implicit move generation User-defined literals

Universal character

names in literalsthread_local

Function template default arguments = delete Ref-qualifiers:

& and && for *this noexcept Expression SFINAE

C++11 preprocessor

(incl. C++98 & C11)

Delegating constructors

“using” aliasesC++14 libs: type

aliasesC++14 generalized

lambda capturealignofalignas

Inheriting constructors

C++98 two-phase lookup

Uniform init & initializer_lists

C99 variable declsC99 _Bool

C++14 auto function return type

deductionconstexpr (except

ctors / literal types)constexpr

(literal types)C++14

generalized constexpr

Variadic templates C99 compound literals

C++14 generic lambdas

C++14 decltype(auto)

Inline namespaces

C++14 dyn. arraysC++14 var templates

C++14 libs: cbegin/ greater<>/make_uni

queC99 designated

initializersC++14 libs: std::

user-defined literalschar16_t, char32_t

Post-RTM OOB CTPWhat we’re currently implementing, roughly in order… some subset in

CTP

PlannedWhat’s next for full conformance

Page 42: Approval Detailed Specification Design Investigation.

You arehere

ISO C++ timeline: The “C++14 wave”

98 99 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18

C++98(major)

Library TR1 (aka TS) Performance TR

C++03(TC, bug fixes only)

C++11(major)

C++17(major)

C++14(minor)

FileSysTSNetTS1Concepts

TS

14

Page 43: Approval Detailed Specification Design Investigation.

Conformance roadmap: The road to C++14 waveVC++ 2013

Previewtoday

VC++ 2013 RTMlater this year

Explicit conversion operators

Non-static data member initializers

__func__Extended sizeof

Thread-safe function local static

initUnrestricted

unions Attributes

Raw string literals = default Implicit move generation User-defined literals

Universal character

names in literalsthread_local

Function template default arguments = delete Ref-qualifiers:

& and && for *this noexcept Expression SFINAE

C++11 preprocessor

(incl. C++98 & C11)

Delegating constructors

“using” aliasesC++14 libs: type

aliasesC++14 generalized

lambda capturealignofalignas

Inheriting constructors

C++98 two-phase lookup

Uniform init & initializer_lists

C99 variable declsC99 _Bool

C++14 auto function return type

deductionconstexpr (except

ctors / literal types)constexpr

(literal types)C++14

generalized constexpr

Variadic templates C99 compound literals

C++14 generic lambdas

C++14 decltype(auto)

Inline namespaces

C++14 dyn. arraysC++14 var templates

C++14 libs: cbegin/ greater<>/make_uni

queC99 designated

initializersC++14 libs: std::

user-defined literalschar16_t, char32_t

C++TS concepts lite

Post-RTM OOB CTPWhat we’re currently implementing, roughly in order… some subset in

CTP

PlannedWhat’s next for full conformance

Page 44: Approval Detailed Specification Design Investigation.

One more thing for the next OOB CTP

Page 45: Approval Detailed Specification Design Investigation.

Continue to deliver C++11More batches coming in 1H13

Continue to investin platform supportWindows Store apps• Continue to bring C++/CX forward to solve

problems like asynchrony• Continue to make extensions/rewrite less

intrusive to existing C++ code• Example of both: await

Phone apps• See also: Writing C++ components on

Windows 8 & Windows Phone 8Azure (e.g., Casablanca)

VC++ next steps

from Nov 2012

Page 46: Approval Detailed Specification Design Investigation.

Conformance roadmap: The road to C++14 waveVC++ 2013

Previewtoday

VC++ 2013 RTMlater this year

Explicit conversion operators

Non-static data member initializers

__func__Extended sizeof

Thread-safe function local static

initUnrestricted

unions Attributes

Raw string literals = default Implicit move generation User-defined literals

Universal character

names in literalsthread_local

Function template default arguments = delete Ref-qualifiers:

& and && for *this noexcept Expression SFINAE

C++11 preprocessor

(incl. C++98 & C11)

Delegating constructors

“using” aliasesC++14 libs: type

aliasesC++14 generalized

lambda capturealignofalignas

Inheriting constructors

C++98 two-phase lookup

Uniform init & initializer_lists

C99 variable declsC99 _Bool

C++14 auto function return type

deductionconstexpr (except

ctors / literal types)constexpr

(literal types)C++14

generalized constexpr

Variadic templates C99 compound literals

C++14 generic lambdas

C++14 decltype(auto)

Inline namespaces

C++14 dyn. arraysC++14 var templates

C++14 libs: cbegin/ greater<>/make_uni

queC99 designated

initializersC++TS?

async/awaitC++14 libs: std::

user-defined literalschar16_t, char32_t

C++TS concepts lite

Post-RTM OOB CTPWhat we’re currently implementing, roughly in order… some subset in

CTP

PlannedWhat’s next for full conformance

Page 47: Approval Detailed Specification Design Investigation.

It’s very helpful when implementers step up to create prototype versions of proposed featuresGCC (partial list)• (Dos Reis) Variable templates: Voted into draft C++14• (Sutton) Concepts Lite: Prototype underway to complete library, active in

Study Group 8 “Concepts,” Technical Specification expected in 2014

Clang (partial list)• (Smith) Generalized constexpr: Voted into draft C++14• (Vali) Generic lambdas: Voted into draft C++14• (Gregor) Modules: Prototype underway, active in Study Group 2 “Modules”

Visual C++ (partial list)• (various) enum class, nullptr, lambda syntax, delegating ctors:

Included in C++11• (Gustafsson) async/await: Next VC++ CTP, active in Study Group 1,

“Concurrency”

Contributing to “existing practice”

Prototypeville: Laying groundwork for C++14/17/…

Page 48: Approval Detailed Specification Design Investigation.

Example: Concurrent waiting.get .thensize_tfile_sizes( string file1, string file2 ) { task<file> f1 = open(file1), f2 = open(file2); return f1.get().size() + f2.get().size();}

task<size_t> file_sizes( string file1, string file2 ) { task<file> f1 = open(file1), f2 = open(file2); return when_all(f1,f2) .then([=](tuple<file,file> fs) { return get<1>(fs).size() + get<2>(fs).size(); });}.then + await

task<size_t> file_sizes( string file1, string file2 ) __async { task<file> f1 = open(file1), f2 = open(file2); return (__await f1).size() + (__await f2).size();}

Page 49: Approval Detailed Specification Design Investigation.

Real payoff: Branches and loops.get .thenstringread( string file, string suffix ) { istream fi = open(file).get(); string ret, chunk; while( (chunk = fi.read().get()).size() ) ret += chunk + suffix; return ret;}

task<string> read( string file, string suffix ) { return open(file) .then([=](istream fi) { string ret, chunk; while(

?

Page 50: Approval Detailed Specification Design Investigation.

Real payoff: Branches and loops.get .thenstring read( string file, string suffix ) { istream fi = open(file).get(); string ret, chunk; while( (chunk = fi.read().get()).size() ) ret += chunk + suffix; return ret;}

task<string> read( string file, string suffix ) { return open(file) .then([=](istream fi) { auto ret = make_shared<string>(); auto next = make_shared<function<task<string>()>>( [=]{ fi.read() .then([=](string chunk) { if( chunk.size() ) { *ret += chunk + suffix; return (*next)(); } return *ret; }); }); return (*next)(); });}

.then + awaittask<string> read( string file, string suffix ) __async { istream fi = __await open(file); string ret, chunk; while( (chunk = __await fi.read()).size() ) ret += chunk + suffix; return ret;}

Page 51: Approval Detailed Specification Design Investigation.

WinRT + Ref Class on the Stack.get .then{ DataReader rdr(stream); auto bytesRead = rdr.LoadAsync((int)stream->Size).get(); txtBox->Text = rdr.ReadString(bytesRead);}// Re-open file here.

auto rdr = ref new DataReader(stream);task<uint32>(rdr->LoadAsync((int)stream->Size)).then([=](uint32 bytesRead) { txtBox->Text = rdr->ReadString(bytesRead); delete rdr; // Re-open file here});

.then + await{ DataReader rdr(stream); auto bytesRead = __await rdr.LoadAsync((int)stream->Size); txtBox->Text = rdr.ReadString(bytesRead);}// Re-open file here.

Page 52: Approval Detailed Specification Design Investigation.

Conformance roadmap: The road to C++14 waveVC++ 2013

Previewtoday

VC++ 2013 RTMlater this year

Explicit conversion operators

Non-static data member initializers

__func__Extended sizeof

Thread-safe function local static

initUnrestricted

unions Attributes

Raw string literals = default Implicit move generation User-defined literals

Universal character

names in literalsthread_local

Function template default arguments = delete Ref-qualifiers:

& and && for *this noexcept Expression SFINAE

C++11 preprocessor

(incl. C++98 & C11)

Delegating constructors

“using” aliasesC++14 libs: type

aliasesC++14 generalized

lambda capturealignofalignas

Inheriting constructors

C++98 two-phase lookup

Uniform init & initializer_lists

C99 variable declsC99 _Bool

C++14 auto function return type

deductionconstexpr (except

ctors / literal types)constexpr

(literal types)C++14

generalized constexpr

Variadic templates C99 compound literals

C++14 generic lambdas

C++14 decltype(auto)

Inline namespaces

C++14 dyn. arraysC++14 var templates

C++14 libs: cbegin/ greater<>/make_uni

queC99 designated

initializersC++TS?

async/awaitC++14 libs: std::

user-defined literalschar16_t, char32_t

C++TS concepts lite

Post-RTM OOB CTPWhat we’re currently implementing, roughly in order… some subset in

CTP

PlannedWhat’s next for full conformance

Page 53: Approval Detailed Specification Design Investigation.

When is the next roadmap update?“Let’s get together / Before we get much older”

Page 54: Approval Detailed Specification Design Investigation.

GoingNative 2012

Page 55: Approval Detailed Specification Design Investigation.

September 4-6, 2013Redmond, WA, USA

Bjarne Stroustrup (Texas A&M) Chandler Carruth (Google)Scott Meyers Stephan T. Lavavej (Microsoft)Andrei Alexandrescu (Facebook) Sean Parent (Adobe)Michael Wong (IBM) & more…

GoingNative 2013

GoingNative 2013

+ RTM/CTProadmap update

Registration open todayhttp://is.gd/goingnative

Page 56: Approval Detailed Specification Design Investigation.

© 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.