So welcome. Have you ever gone to see
The  third movie in a series and found that the  people
In your group who had never seen the  previous two enjoyed
It just as much as those who have seen the previous two?
That's the  trick. That's what i'm aiming for here.
We  took some pols before we started here, before  the
Camera started rolling, and it's close to  50/50.
Who people who use c++ as their  project today.
There are quite a few of you who have seen  c++ in the
Past and have been amazed perhaps  of how much it has
So this talk is  intended to have something that each
Of you  could use. We're going to focus on how
To how we can adopt c++, mode mode in our existing c++
To reinvent the world. But even if you are new to
C++, maybe you had  a hans to work with c++ before, this
Talk  should be good for you. It should give you a  nice
Modern c++ is. If you  are one of those
People who have been using c++ for over ten years or
More, a few of you,  probably online, i'm sure there are
A few  slides where we're going to go deep in a few
Areas, and i think that you will find dollars  to doughnuts
That there is something you didn't know or didn't quite appreciate as  much.
Certainly we're going to cover some  things in c++
11. After c++ 11 shift.
Let's  take a look at this survey and in accord with
The title of the talk, with a view to how do  we adopt
Modern c++ in our existing code. So the first thing i want
To do is cover the  difference between the classic c++ that
We  might have done in the 1990s and 2000s, to  modern c++.
We're going to talk about vocabulary types in interfaces.
We're going to talk about two major mindset  issues.
If i'm going to use c++ well in  independent i don't
Mean mat i cannily and  realize its strengths, what do i need
How can i think about it. This  applies to how we
Update our coding. Some of  these things are
Classic. Ways to express them down.
Then  final by we're going to talk about pointer,  because
What would a c++ be like without pointers. We're going to have fun there.
Let's start with the book that you should  know that
You should recommend. If you are  looking for
A book that has in a couple of  hundred pages, what every
Should know, this is the book to  recommend. The second edition is on
Its way  to the publisher and should be out around
July of this year. The first edition is  great
And you  might notice that the author is fairly well
Known in c++ circles. And if you don't  recognize
The name, else mr. C++, the guy who  invented
The language and still involved with  the evolution towed
And leading that fight. It's going to be updated
Soon for the current  standard last year.
C++  17. At
We're going to say is  going to be found more detail there.
Let's  talk about classic and modern c++.
If you  have seen c++ code that was written more than
Five, seven years ago, it looked a lot like  the code
T-hand of the screen.
New  deletes, repetitionousness and boiler plate.
And the most important thing that i can say  about
That code, especially at a talk on my  grading and adopting
Modern c++, is we can do a lot of this better now.
But that code works. It works now.
It's  still is valid. It still works as well as ever.
If it had pitfalls, the backward  compatible story.
We hardly break backward compatibility. That code you worked 20
Today. But if you're updating the
Function, or  writing new code, you might find that
You can  do the same in fewer lines with equal  efficiency.
This is not turning c++ into c#.
This is letting us to spell c++ with many of  the features
You enjoyed in modern languages. Like automatic type deduction
In variables. Instead of raw pointers,
We can use share  pointers that will allocate the object for  you.
And you notice i didn't say lead  anywhere because
It's counted for me  automaticall y. The four loop in the middle, is arranged.
Not only is it easier to spell  but that is robust
And readable which is a  key thing because you can just
Read it and  without looking at the body of the loop by
Construction know this visits every element  in the range
From first to last. There's a lot to like here.
And it avoids  the pitfalls on the left-hand side like
Safety, and leak things. Automated  for you.
That does not mean that you should  rewrite all the
Code on the left in the right style unless you're touching
That function  anyway. You did not need to rebuild
The  world. Thg what you do.
Strong compatibility  story and the code on the left is clean now.
Just as fast as ever. As an example, picking another
Modern  language, python is a nice clean language.
The point here isn't to say, look language a  and
B, it's competitive. No.
The point is,  you can write clean code in any modern
Language, that includes modern c++. So if you look at the mean
Function in python  you can write it line for line with
The same  meaning in c++ today and there you'll notice  things
You he we used in the previous slide. And some of you might realize
That oh, in  python i wouldn't write that for loop.
I  would just use some in length. And the c++  library we've had that.
We've had reduced in  size. Yes, you can write that
Yourself. One  of the new things i'm
Not going to talk about  in detail but works today in
The shipping  today in visual c++ that's new in c++ 17 is
That st ll on the right-hand side reduced. How many of you are familiar algorithm.
How many of you  know that you can make that run in parallel
R? uh, one. And this with run on  multiple
Course, on a large data said or wide  machine and i can
Wrap them in a function if i want to to have the same
On the left-hand  and over length. But that gives you the idea
Of the power available and tuesday didn't  come on the
Cost of manual management of  things that poem cirque
With c++. Now, don't  worry.
C++ has always had as part of its  ethos, not only zero
Overhead but now when we enient
, We allow you to open  the hood and do things by hand
You always have the ability. Unlike  other languages
That prefer to keep that hood close.
You can do it over data lay outs and  data structures
Are organized. You'll find  many of the
Time you don't need to. The  clean thing is fast
And efficient by default. You
Let's talk about a couple of specific things  that are
Part of mode mode. Move semantics  was probably
The most important fundamental feature that was added to
The language in c++  11. There are four important
Vocabulary  types that were added in last year's standard
That are worth knowing about. C++ has always  been a value based language.
We opponent put  every language on the heap by itself and
Carry around point ores to them.
We have  values on the stack. We can put values  inside
Other values and so it's a ge.
And what c++ 11 did is double down on that.
Now, you've always been able to have things  like an efficient
Second at that vector of wing ed objects. We can make that efficient.
But you never in the past ft-hand
Return by value. We spent a lot of time
Teaching people don't do that. Because you  take the whole
Copy of the container, then you throw away the original
And make a copy  again to return it to the caller.
That's silly. So we say, no, no, move
It up  on the heap, put a pointer to it and so we  can control ourselves.
And it's efficient. You can get the efficient
Allocation or raw pointer, you say, no, no  that thing
We told you don't return to value,  it's okay now.
Just return by value. And the reason is the  c++
Has not just now copy operations which  are a deep copy save
The whole container in  this example. But they have the idea of
The  move operation. Hefty, expensive value from
Here to here when  you do a copy you do a deep copy of  everything.
And so at the end of the copy,  all the data that's
Under here is still there and now copy if it's under
Here. When you do  a move, we
Of  pointers and say, i'm going to own your data  and
We leave this guy empty which if you're about to destroy
That source object anyway like in this  example.
So return by value is cheap for nearly all  types now.
Container. So we can use efficient
Value  semantics but we get the efficiency of  reference types.
Think of this as a major opt l optimization and doubling
Down to c++  commitment to value types. There's value  based as ever.
You can write base classes if  you want.
But we're still as much in the  business as value
Types as ever but now  there's efficiency.
Now let's talk about four specific vocabulary  types
That you'll find yourself using quite a  bit and in
Particular the first two are ones  that you will use frequentl
Y on interfaces. So these are new in c++
17. How many of you, have enjoyed
Using more than  one incompatible string class? [laughter].
Laughter ensues. How many of you just  curious
Now, notice the cameras are not on  you, the backs of
Anonymous. How many of you written
One of  those custom string classes?
20, 30 People. So we have all these spring
Classes. People  build them.
Of there have been historical leads for that kind of thing.
But when you  are writing a function that accepts a
Spring  as input what do you have to do in classic  c++?
A c style way,  you can get the pointer and the length wrong.
So that's the kind of thing that leads to  buff overflows
And things tyke that. There's this new type, string
View, v string  view for wide characters where you can write
A non-template function. That function on  the right-han
D side is not a temperature plate. But it can take characters
Regardless  of string types. The string types that know
About string view, or string view provides a  construct tore from.
If you have a standard w string you can pass ffs.
And it will take  a string view. Think of it was a pointer length pair.
It's a pointer that knows its  bounds and iterate on
Ver. You can passion it. If you have in the second
Line a character  pointer and length.
You can pass that. Now  notice this.
In the old days if you had written your function f to
What have you have written. -- But  you'll notice here,
You write exactly the  same thing but there are two additiona
There are the brace characters. And this is part of a general
Modern c++  feature called uniform initialization.
The  extra green braced them.
It makes them a spinling parameter and says, construct
Me an object to  pass. I didn't say the type.
I don't have  to. I know the type of parameter.
I don't  need to repeat myself.
And i pathology as  the single parameter, a brace
List of a  couple of things, it says, i know what you
Want me to do, you want me to convert that as  the konstrukt
Of aw string view. Okay. And  i get the exact same
Today. Except i put two  braces.
You find this to be convenient in  many cases without a lot
Of certify moany. I  don't have to repeat
The type. It's clean,  and i still
Get the benefit of that f function can take a character
In any of these things. If you were in the c++ in
T talk, you notice  the line-- it has an explicit conversion
To  spring view. Guess what you can say ffs
Without decoration because it notes how to  convert to
A string view to give you the  characters in the string.
The forth example is qt. How many of you use  that?
The example there does not compile yet  but is likely
To come bile pile on a release soon now without spelling
To convert to a  string view. Of course, you can still
Today  use the pointer coma data and  dot length.
From the other strings, you can  convert it to the
Pointer in the length,  which ever way those springs happen
To  provide that information. And you can use  all of
Them to call string view. And the nice thing about this
Is i did not  have to write a template.
Question-- >> (speaker away from mic)
>> How about a vector of charge you can sue  the same thing
With a vector of charge. Yes. Because this is the one
Thing you must  remember and therefore it is in a special
Color on the screen. Because vector of  charge
Is not guarantee today terminated neither is this.
Do not take a string view and call dot data and pass
It to something  that experts an allege internal in a tore
It  will continue onto doing the same thing-- not  what you wanted.
Just be aware. This is an  an terminator
View. It's really a sequence
And i'm agnostic  about what spring type happens to own
It. And i can use those characters
That's the  first. The second, which you'll also
Use a lot of  interfaces, you probably noticed the spring
View, you'll use that a lot as a parameter  type to come
Into a function to pass data into a function.
Optional you will use as a  parameter or a return type.
If you're  familiar with nollable
In other  languages, it's applied to a value not just
A  pointer. It says, "a create function
String. That's not an empty string.
I can do that if  i return plain string. If i return optional  string.
I can return any kind of on value.
Then i can test for it. I call create and i can
Say if results. So  that's a shorthand if
Go ahead and use it. If i try to use the result,
And i didn't  check first, it will do the check for me.
But, if i'm wrong, it will throw. So if you  want to make
Sure your code doesn't throw an  exception.
Do the first part of main there  to check the result first.
But you can try  to do referenc e, you access the value, and
If  it's not there you get an exception. And you  can handle that
As you want. And finally sometimes you
Just want to say, i  have an optional string and i want
Tow use  its value or use the default value if its
Empty. There's a function for that.
Use  results value or empty. That's why that  exists.
If result is not empty, you'll get  results value,
If it is empty, you'll get quote, empty quote as your
There. There are other functions
That but gives you  a flavor of how you use it.
This could be  useful on functions that return a value
That  might or might not exist. And if you want to  express
That, this is a great way to do it in  new code.
A variant is should go a bit different. You'll use this within
Function body or as  data as you store someplace.
A variant is  like a union that knows its type.
If you use  unions and you're scared because they're  unsafe,
This is the safe version of that.
What it says, is here i have a value which  always contains
A single value except in stain not situations it could
Be empty, but  that's not the part of the main use of the  feature.
It's a value that has exactly one  value but it can be any
One of these fixed  number of types one at a time.
So i can  actually make a variant that could be ab
Interor double. It's variant in double.
It's  dynamic type is int off the code. If i ask  to get the int
That succeeds in print 42. If  i try to get a double,
It will say, no, no,  i'm holding an int.
It's a dynamic check and it will throw. But i can go with the same
Variable a few lines above wasn't an int.
Assign it a double. And now i can get a  double
And it's fine. Think of it as a safe  union.
It remembers its type. It's type  safe.
You get an exception if you do it  wrong.
Because it's part of the standard  library.
This is a widely used time. You  can expect implementations
To be efficient. You can expect implementations
To keep  allocations if you're very close to variant, is any.
So as soon as  people say variant, one of the first
Questions, what if i want a variant, and i  want-- just
That behavior, a single value, but a different type and
Points in its  lifetime. But i don't know the types in  advance.
It could be really any type. This  is for any type.
This is a library for truly dynamic types in c++ standard.
So now i can say, auto a equals ne42. I have  an fe varrable.
If i cast it to a string, that will throw and get the
Exception. Later  i can assign a string
To it and it holds the  string and homes just fine.
If you need a  fully dynamic type, use that. >> (Speaker away from mic)
Use it to find  types b in that mix, absolutely.
You can  write your own type. With few restrictions,
Pretty much anything could be put in.
In  this example, we use a standard string or you
But you can use a vector or something that  you wrote.
So that gives you an overview of flavor for  classic versus modern c++.
The old still  always works but now we have new ways to
Express things in new code or as we refresh  old code,
Move semantics because we're a  value based language but
It's efficient, and  those vocabulary types.
But now let's talk about two general concepts  or techniques
That have been always part of  c++ and some continue to be.
And i include  this part of the talk especially because
We  often will find people who use receive not  only
As their primary language. They're  familiar with idioms
6 Another language. If  you want to write idiom
Mat i can c++ well. If you allocate any heap
Allocated resource  or dynamic resources, pass tow to the
Construct or of the object is going to own  and it deconstru
Ct tore who will release it. If you do that, if you make
Sure allocated  resource is distractor is going inform
Release, you're  going to have a great time this c++.
New, we tell don't write new. Write unique.
It's a smart pointer  who's konstrukt will delete the
Heap object  and it's just an efficient if you delete
By  hand. But now we have that owner
Object. We  will talk about spart
If you open file and # owns the file and the  distractor
Will release and you get automati c  clean up and life is wonderful
In fact, if  you have a class that contains an object
By  value, same thing happens. When the gadget is destroys
As part of  destroy the enclosing anything you own.
And the wing ed diss  tractor if you committees  troy.
The widget it will wrought country  call the giang et
Committees tractor. If you  have java in dispose
Method that owns an  upper object and owns an inner object,
You  wire up the inner dispose, that's automatic.
We wire that up for you and similarly if you put an
Object on the  stack as we saw in the previous slide,
The  idea is, in c++, if i where
, It's lifetime is controlled by its  enclosing scope and
That scope could be a  function scope, another class, another
Object  scope. If the other scope goes
Out of scope  or committees troyed. S toyed
We clean up inside it. You can maybe that efficient
And useful. Now, one thing about exceptions,
Many people  are fine with using exceptions because they come from languages.
That's the only way to report errors.
Those of you who were been using c++ know that there
Are places where  there's a debate whether to use exception
S or  error codes. There are valid reasons
For  that. This slide and the next
Tries to  summarize how to doer roar handling in c++
As  we do today. The first thing is, know what
Error is. Means the function you called
Could not  achieve what it advertised.
It's free  conditions were met but it could not achieve
The post conditions, maybe some resource  needed wasn't
Available tore something else happened or the data given
Pars it. Only this in those cases report
Things as a  recoverable error. Once we define it, the
Advice is to use prefer-- you have to convert  that to an error coat.
Prefer to use  exceptions because they're not i go norred
By  default, they prop gate automatically.
They  work great in konstrukt and operators.
And  they keep the normal control flow separate  from
The air handling catch control flow in  the callers, and
Air codes don't do any of those things. So prefer to use exceptions
Those of you who mostly use other languages  will go,
Well, yeah, of course. We always do  that.
But sometimes we have to teach that in  c++ because
There's a heritage there and there are sometimes reasons
Why air codes get  used. But the main thing is, what's
A recoverable  error and prefer to report them using  exceptions.
What is not a recoverable area  is a precondition violation
If you are  calling a function and you did not meet the
Preconditions, the function has no hans to do  anything sensible.
And the way you should always think about a  precondition
Violation, and this is true in  any language, this is
A totally generic csc  thing. If your caller violated
One of your  preconditions, it's not that you're going
To  be corrupt, your program is already corrupt.
Something is nonsensical. It is not what the  program
Was intended to be able to respond to  automatically.
Therefore it is hopeless for  the program to do anything
Sensible. For that kind of condition,
Don't think of  that as a recoverable error because
It's not. Therefore don't report
It as an exception. Use konstrukt which and
Which is hope freeway  coming to c++.
And report that to a human being at test time.
You want to make the  developer aware that you violated a
Has to fix it. Means you have a bug.
Whoever owns  that code body needs to go fix it.
Let's spend the rest of our time talking  about pointers
Because this is an important area of c++.
And it's one where the practice is most  visibly different
From classic to modern c++. In c++ we have long been
Familiar with code  like this. Where a factory returns
A i raw  pointer. We try to use them.
We make sure  that we explicitl y delete our locally  allocated
Objects and all that red code now  is mostly wrong.
Now we tell people don't do  that and it wouldn't passcode
Review as new  code. But remember we have a great
Backward  compatibility story. That code still run as
But for new code  that should fail a code review because
We  have an opportunity to do better in new code.
In particular, the factory should do by  default unless
You have a good reason to return a unique pointer.
I need to allocate  the heap object and pass it back.
What's  what unique pointer is good for.
A single  ownership of heap value.
I should be using  local variables and not doing local
News as  and that helps to manage my exception safety.
It automates resource clean up. I don't need  any deletes,
I don't have to wore yeoh whether they fire, if there's an exception.
The code on the right will clean up even if  there's an exception.
You don't have to  write a dispose function if you're
Familiar  with that from java or c#.
If you're  allocating a heap object, prefer make unique
By default. And the other major make
Function like that to allocate use that one if and only
If you  know the object is more than one sharepointer,
Smart pointer  pointing to it. You can always on vert from
Unique to share  later. If the object you're aloe
Karat might  only be used in one pointer for the life of  the program.
You can use new nick. 23 You  know it's going
To be shared. We can do an  optimization for you.
Save you an allocation , too.
Whatever you do, don't write delete.
That's  the most important thing we have to learn.
Now having said that, when smart pointers,  any new thing,
Especially a good thing will the #1 pitfall of c++  smart
Pointers and while a lot of people have  helped them get
The operation of being slow is they say, oh, smart pointer good.
I will  use that everywhere. I will pass them by  value
And we will talk about that in the next  slide.
But as function parameters and return values,  raw pointers
And references are just fine. Note the previous slide
Said to avoid owning  raw pointers. And owning raw pointer is
Ease  injury to discover, identify. It's the one  you have to
Call the lead on. But a pointer  is something
That you borrowed, you're referring to somebody else's
Object. As long  as the life time
Exceeds yours. You don't  have the responsibil
Raw  pointer is just fine. You'll notice the classic
And the new is  identical on the slide because this
And if you're using a  unique pointser or shared pointer,
To ps a reference,-- if you're parameter.
These are nice and efficient. Raw pointers and references
They're a machine  word. It doesn't get more efficient than  that.
Those are fine. There are times you want to
Pass a smart  pointer only if you need to talk about the  smart pointer.
I'm show exam pls. Here's one of those slides
Even if p you know  c++ had modern c++ well, you might discover  something new.
So sometimes i hear people say, well, smart pointers.
But raw pointers  are easy conversions,  automatically
Pointers to conses. Yep, so  does smart pointers.
Smart. There's one thing people say
Sometimes. I  know smart pointer can't
Do the should go. Sometimes i don't want
A pointer for the  whole object. Sometimes i want to point
To a  component of the object, say the data object  that's
Physically inside a node oob. And my  data structure has
All these shared pointers to nodes.
I don't want to tell in i caller  about nodes.
I want to give them back up to  the data.
Obviously i need a-- that last  line of code is a trust
Me. But as long as  you get
That one line wrong, this what you're doing is you're
Saying, i  have eye pointer to a node. Make me a  pointer to, shared
Pointer to data that  shares the reference count of this
Pointer to  node and has this raw pointer to a date.
As soon as you construct that on the last  line, you have
A shared pointer to the data and it shares the reference
Count even one is  pointing inside to a nested object,
And that  is perfectly type safe.
The caller can use  it just fine.
And it later on, essentially, you know when the last smart
Pointer goes  away, the object gets destroyed.
It doesn't  matter if it's the in or outer one.
They  share the same reference, count lock.
They  both know the full object's type and what  december tractor to call.
So it doesn't  matter which is the last to go away the
The  object gets cleaned up this is a handy  feature and
One i discovered after i shipped the standard because i needed
It. And  sometimes you learn about things not until  you
Need them. The good news is c++ is
Full  of things that you don't have to know if you  don't
Need them. But if you look for them,
They're most likely to be there especially  opening
The hood and taking control like this  in most language.
That's something c++ has always placed a priority on.
But again, do not needless pointers, this is to calm
Pointers,  c++ that don't have ptr in their name but
Behave like smart references that, when you  copy them
Do them in increment, deck amount. If i'm writing a function
And all i'm doing  is using if i'm not using the  smart
Pointer in this. The  widget.
All that does is you can only call  me with widgets
That happen to be owned in this way which is a destruction.
Worse is people pass it by value, and worse  is if they
Of  smart pointers. Please don't do that.
When  people do this, smart pointers get a  reputation
Of being slow. It's because  they're asked
To do needless work. Because  it's common, i point it out.
Is this a real world thing? s.
They used to be passing sharepointers by value all the time.
The  thing we said don't do that. Them by reference like the
Top  left. That's the quickest mechanical
Fix in  the code and you should take out the smart  pointer.
Some benchmarks went up 400. In query, in database-- in
The transaction  per second, they were  performing.
They were spending a fair amount  of time hitting the
Cache lines, increpting  those lines. You say, it couldn't be
True  anymore. When you went to kenny's
Talk, he  had c++ factory cache.
And noticed it was a  bottle neck. He noticed it has to be
It was taking mutex lock time you access the factory.
Wonderful thing. Sometimes we  blame mutex.
He had an extra return, a smart  pointer by value,
That wasn't even needed and it was that increment deck
Represent, that  was consuming more than other of the time in  the function.
Now, why? because air smart pointer,ible
Crept, decrept. Has to be safe.
It's an  automic function. Most will have the time
You need to do it anyway. That's why they're  just
As efficient. Written by hand.
If you do them needlessly, if you start using  spart
Pointers and notice your code getting  slower.
Look for this. And you can fix it  because
It's just the trap that's easy to  fall into. So that's the #1 performance
Problem with  using smart it's avoidable when  used correctly.
Now let me talk about the #1  correctness fit fall.
Most people remember,  referenc e counter pointers don't do cycles.
You need a weak pointer in there.
And they  can remember that. But sometimes when we reenter
Code, we go  through deep call, which happens all the
Time  now when we have call back-- we're going deep  into
A call tri. We have to remember, that
The object we're pathologying ssing down
From way up here, we  have to make sure it lives.
The pitfall is,  if there's something deep down below,
Could  be ten, 100 levelings below that could  invalidate
That object by sod identifying the  smart pointer that owns
It. The way you deal  with that
Is make sure the smart pointer that  owns is not something
Here. Let's say i have this global
Called other p. In my function f p,  i take
Ape widget reference as we said we  should.
This is going to be a widget we can  do something with.
I call other helper  function g. And i use my widget.
The author  of f did nothing wrong.
Void g-- i decided i  need to reset other p to something.
You see  the problem? if it could ever be that inside
Function g,  when i reset other p, i might have taken
Away  the last reference count to that.
And if  that widget happened to be the one that when  i
Returned to my caller was the one passed to  caller
F i could have just destroyed that  widget which could happen
If i do this call  site. So this should not pass code review.
And you  might say, ugh, that means awfully subtle.
But there's an easy way to spot this.
Doing in the red code. I'm getting a raw pointer
Reference something owned by a smart pointer  and passing
It down to code that can see the  smart pointer and therefore
In this case, it's easy to see that.
It's a global. Also passing a pointer that
Smart pointer to keep the object alive,  that's the
Pattern to look for. Instead the  fix is simple.
Take a copy of this reference counter pointer.
You're taking a copy which i told you don't do unless
You need to. This  is a place you need to.
I take one coppy and  now i have a local pin, because
It's pinning  a reference counter to make sure this
Widget  stays alive. And then i pass a raw pointer
I  get from the pin. This is perfectly safe and
Cannot possibly fail because that pin  variable, is unalias.
There's no way the  implementat ion of f or anything it calls
Can  know about that pin value. It's not global.
It's purely local. And you might say, a tom
I can, increment, deck amount, good reaction.
Apply here because we're taking one reference  count
Bump that protects it. It's only  converting on
Smart pointer to a raw pointer, you hold the pin and that
Single reference  count protects the entire million instruction actual tri.
The same thing happens when you say using the  arrow operated
Call and member function. Same thing.
That's also a conversion to a  raw pointer.
We're getting a raw-- we can  call the fu function.
Make sure you take a  pin. If you're converting to
A smart pointer  to a raw pointer, make sure you're
Converting  from a local copy. Nothing bad can happen to you.
This happens in the real world code  bases, too.
The edge team -- this is several years ago.
They they happened to only a javascript  run-time implementa tion.
From their c++ code  they would pathology a call pointer
Through  javascript which would come back to the c++
Back-- sometimes the objects had disappeared because of this reason.
You  take the pin and the problem can't happen.
It doesn't matter what you don't have the code.
You know you  have a safe, count nobody  else can see
And it protect the whole call. Quick guide to smart pointer--
If you know it's going to if you are syncing function,
That  means you're taking ownership away from the  caller,
Or you're expressing i'm a receipt take it by  reference
And swing that reference to make  the unique pointer maybe
Widget. And  the same thing with
Pointers. Sharepointer.
Only if you really want to make a statement  about own irrelevant ship because
Every  single one of these is making a statement  about
The own irrelevant ship. We're  retaining reference count.
I'm transferring  the reference count or something like that.
So here's the summary of everythi ng we just  said, the reason
I put this slide in, it's repetitive to everything
I said, but puts it  in one place because you can print
It out and  put it on the of whoever needs  it.
Sometimes we keep it for ourselves.
It's a handy reference to have.
I'm told it  makes a great mouse pad. That's everything we're talking about.
Please remember to complete uations.
And we have time to answer questions for  anything we've
Covered. Can you please use  the mic.
>> Sure. So for
-- Go ahead.
Some va automatic  conversions for string view.
Is there any  mechanism sort of the stood hash variance
Where you can  provide your own implementation for an
Automatic conversion so you don't have to  specify the
Conversion code. Have conversions-- it's  that
Conversion to spring view. When he did his string, had
Expolice out conversion to a string view. When i mentioned the coup
Example, they  decided to do it initially-- i reported
This  two weeks ago. It looks like they want
Function where i show  the tentative name from their
Bug report  there. They're also considering
Make iting  an implicit come version by making it a w string view.
If your string type is 30 years old or not  updated.
Use the pointer length extracti on  function however they're
Spelled and make a  string view around it-- match the
Character  type. They're plain spring view
Is-- w  string view is w chart ts which is not  necessarily 16 bit size.
Chart 16t is not  the same as w chart t.
There's a user string  view. There are a few variations.
Character type. >> I usually program in c
Carp but i also do  c++. What construct-- try catch
Then (inaudible)  i'd like to know the reason why it's
Not there. So one reason is  there's
Less need for it. It's proposed  styled.
If you follow the voice what's -- for instance, in
Java  the #1 use for finally was finally disposed.
The disposed 359 eastern you wrote by hand.
That's the default in c++. You never write  anything.
It's white space. Still people ask for it
And  sometimes it's proposed. But it's unlikely  we'll other it.
In one of the slides, gsl finally, there's a gsl guideline
Support  libra ry, and you
Can find a type there. However, the guidance on
That slide was used  as a last resort only.
In a nut shell, what you should do, if you  don't have
An iar type, write unone.
Everything just works. When you look at the  uses
Of finally in the wild when they've used  gsl finally,
There's some in boost or scope guards. Every time i've known this
To be  automatic tided, windows had one-- when they  audited
The uses, over 50 were wrong. That may resinate with you
If you
Debug java  code. Occasionally it's useful
That's why  you have gsl manually manual and not automatic.
You have the  responsibility of taking care things on a
Finer grain level. Automatic is just-- much more
Common and just  as fast as manual. So we're trying to reduce
Those things so you don't have to write it.
One more. >> So one of the things i
Noticed that other  languages do better is package management.
Es, that means  the biggest problem in c++, are there
Any  plans to-- seer 17 solve any of those?
A are  there plans to do that in the few tush.
>> The question is, include files headers,  ugh, and fog
Nt. Pi.
It's not in c++ 17, but those things  are being actively
Addressed. The first  thing is to get
Rid of the need for header look for the  modules, google
Or bing, whatever your search engine is. Standardization as we speak.
And some of it  might be, we'll know next month, it
