<s>
In	O
computer	B-General_Concept
science	I-General_Concept
,	O
a	O
smart	B-Language
pointer	I-Language
is	O
an	O
abstract	O
data	O
type	O
that	O
simulates	O
a	O
pointer	O
while	O
providing	O
added	O
features	O
,	O
such	O
as	O
automatic	B-General_Concept
memory	I-General_Concept
management	I-General_Concept
or	O
bounds	B-Data_Structure
checking	I-Data_Structure
.	O
</s>
<s>
Smart	B-Language
pointers	I-Language
typically	O
keep	O
track	O
of	O
the	O
memory	O
they	O
point	O
to	O
,	O
and	O
may	O
also	O
be	O
used	O
to	O
manage	O
other	O
resources	O
,	O
such	O
as	O
network	O
connections	O
and	O
file	B-Application
handles	I-Application
.	O
</s>
<s>
Smart	B-Language
pointers	I-Language
were	O
first	O
popularized	O
in	O
the	O
programming	O
language	O
C++	B-Language
during	O
the	O
first	O
half	O
of	O
the	O
1990s	O
as	O
rebuttal	O
to	O
criticisms	O
of	O
C++'s	O
lack	O
of	O
automatic	B-General_Concept
garbage	I-General_Concept
collection	I-General_Concept
.	O
</s>
<s>
Smart	B-Language
pointers	I-Language
prevent	O
most	O
situations	O
of	O
memory	B-Error_Name
leaks	I-Error_Name
by	O
making	O
the	O
memory	B-General_Concept
deallocation	I-General_Concept
automatic	O
.	O
</s>
<s>
More	O
generally	O
,	O
they	O
make	O
object	O
destruction	O
automatic	O
:	O
an	O
object	O
controlled	O
by	O
a	O
smart	B-Language
pointer	I-Language
is	O
automatically	O
destroyed	O
(	O
finalized	B-Application
and	O
then	O
deallocated	O
)	O
when	O
the	O
last	O
(	O
or	O
only	O
)	O
owner	O
of	O
an	O
object	O
is	O
destroyed	O
,	O
for	O
example	O
because	O
the	O
owner	O
is	O
a	O
local	O
variable	O
,	O
and	O
execution	O
leaves	O
the	O
variable	O
's	O
scope	B-Language
.	O
</s>
<s>
Smart	B-Language
pointers	I-Language
also	O
eliminate	O
dangling	B-Error_Name
pointers	I-Error_Name
by	O
postponing	O
destruction	O
until	O
an	O
object	O
is	O
no	O
longer	O
in	O
use	O
.	O
</s>
<s>
If	O
a	O
language	O
supports	O
automatic	B-General_Concept
garbage	I-General_Concept
collection	I-General_Concept
(	O
for	O
example	O
,	O
Java	B-Language
or	O
C#	B-Application
)	O
,	O
then	O
smart	B-Language
pointers	I-Language
are	O
unneeded	O
for	O
reclaiming	O
and	O
safety	O
aspects	O
of	O
memory	B-General_Concept
management	I-General_Concept
,	O
yet	O
are	O
useful	O
for	O
other	O
purposes	O
,	O
such	O
as	O
cache	B-General_Concept
data	O
structure	O
residence	O
management	O
and	O
resource	O
management	O
of	O
objects	O
such	O
as	O
file	B-Application
handles	I-Application
or	O
network	B-Protocol
sockets	I-Protocol
.	O
</s>
<s>
Several	O
types	O
of	O
smart	B-Language
pointers	I-Language
exist	O
.	O
</s>
<s>
Some	O
work	O
with	O
reference	B-General_Concept
counting	I-General_Concept
,	O
others	O
by	O
assigning	O
ownership	O
of	O
an	O
object	O
to	O
one	O
pointer	O
.	O
</s>
<s>
Even	O
though	O
C++	B-Language
popularized	O
the	O
concept	O
of	O
smart	B-Language
pointers	I-Language
,	O
especially	O
the	O
reference-counted	B-General_Concept
variety	O
,	O
the	O
immediate	O
predecessor	O
of	O
one	O
of	O
the	O
languages	O
that	O
inspired	O
C++'s	O
design	O
had	O
reference-counted	B-General_Concept
references	O
built	O
into	O
the	O
language	O
.	O
</s>
<s>
C++	B-Language
was	O
inspired	O
in	O
part	O
by	O
Simula67	B-Language
.	O
</s>
<s>
Simula67	B-Language
's	O
ancestor	O
was	O
Simula	B-Language
I	I-Language
.	O
Insofar	O
as	O
Simula	B-Language
I	I-Language
's	O
element	O
is	O
analogous	O
to	O
C++'s	O
pointer	O
without	O
null	O
,	O
and	O
insofar	O
as	O
Simula	B-Language
I	I-Language
's	O
process	O
with	O
a	O
dummy-statement	O
as	O
its	O
activity	O
body	O
is	O
analogous	O
to	O
C++'s	O
struct	B-Application
(	O
which	O
itself	O
is	O
analogous	O
to	O
C	O
.	O
A	O
.	O
R	O
.	O
Hoare	O
's	O
record	O
in	O
then-contemporary	O
1960s	O
work	O
)	O
,	O
Simula	B-Language
I	I-Language
had	O
reference	O
counted	O
elements	O
(	O
i.e.	O
,	O
pointer-expressions	O
that	O
house	O
indirection	O
)	O
to	O
processes	O
(	O
i.e.	O
,	O
records	O
)	O
no	O
later	O
than	O
September	O
1965	O
,	O
as	O
shown	O
in	O
the	O
quoted	O
paragraphs	O
below	O
.	O
</s>
<s>
Because	O
C++	B-Language
borrowed	O
Simula	B-Language
's	O
approach	O
to	O
memory	O
allocationthe	O
new	O
keyword	O
when	O
allocating	O
a	O
process/record	O
to	O
obtain	O
a	O
fresh	O
element	O
to	O
that	O
process/recordit	O
is	O
not	O
surprising	O
that	O
C++	B-Language
eventually	O
resurrected	O
Simula	B-Language
's	O
reference-counted	B-General_Concept
smart-pointer	O
mechanism	O
within	O
element	O
as	O
well	O
.	O
</s>
<s>
In	O
C++	B-Language
,	O
a	O
smart	B-Language
pointer	I-Language
is	O
implemented	O
as	O
a	O
template	O
class	O
that	O
mimics	O
,	O
by	O
means	O
of	O
operator	O
overloading	O
,	O
the	O
behaviors	O
of	O
a	O
traditional	O
(	O
raw	O
)	O
pointer	O
,	O
(	O
e.g.	O
</s>
<s>
dereferencing	O
,	O
assignment	O
)	O
while	O
providing	O
additional	O
memory	B-General_Concept
management	I-General_Concept
features	O
.	O
</s>
<s>
Smart	B-Language
pointers	I-Language
can	O
facilitate	O
intentional	B-Application
programming	I-Application
by	O
expressing	O
,	O
in	O
the	O
type	O
,	O
how	O
the	O
memory	O
of	O
the	O
referent	O
of	O
the	O
pointer	O
will	O
be	O
managed	O
.	O
</s>
<s>
For	O
example	O
,	O
if	O
a	O
C++	B-Language
function	O
returns	O
a	O
pointer	O
,	O
there	O
is	O
no	O
way	O
to	O
know	O
whether	O
the	O
caller	O
should	O
delete	O
the	O
memory	O
of	O
the	O
referent	O
when	O
the	O
caller	O
is	O
finished	O
with	O
the	O
information	O
.	O
</s>
<s>
C++11	B-Language
introduced	O
a	O
way	O
to	O
ensure	O
correct	O
memory	B-General_Concept
management	I-General_Concept
in	O
this	O
case	O
by	O
declaring	O
the	O
function	O
to	O
return	O
a	O
unique_ptr	O
,	O
</s>
<s>
The	O
declaration	O
of	O
the	O
function	O
return	O
type	O
as	O
a	O
unique_ptr	O
makes	O
explicit	O
the	O
fact	O
that	O
the	O
caller	O
takes	O
ownership	O
of	O
the	O
result	O
,	O
and	O
the	O
C++	B-Language
runtime	O
ensures	O
that	O
the	O
memory	O
will	O
be	O
reclaimed	O
automatically	O
.	O
</s>
<s>
Before	O
C++11	B-Language
,	O
unique_ptr	O
can	O
be	O
replaced	O
with	O
auto_ptr	O
.	O
</s>
<s>
To	O
ease	O
the	O
allocation	O
of	O
a	O
C++11	B-Language
introduced	O
:	O
</s>
<s>
and	O
similarly	O
Since	O
C++14	B-Language
one	O
can	O
use	O
:	O
</s>
<s>
C++11	B-Language
introduces	O
,	O
defined	O
in	O
the	O
header	O
.	O
</s>
<s>
std::auto_ptr	O
is	O
deprecated	B-General_Concept
under	O
C++11	B-Language
and	O
completely	O
removed	O
from	O
C++17	B-Language
.	O
</s>
<s>
Since	O
already	O
existed	O
with	O
its	O
copy	O
semantics	O
,	O
it	O
could	O
not	O
be	O
upgraded	O
to	O
be	O
a	O
move-only	O
pointer	O
without	O
breaking	O
backward	B-General_Concept
compatibility	I-General_Concept
with	O
existing	O
code	O
.	O
</s>
<s>
C++11	B-Language
introduces	O
and	O
,	O
defined	O
in	O
the	O
header	O
.	O
</s>
<s>
C++11	B-Language
also	O
introduces	O
(	O
was	O
introduced	O
in	O
C++14	B-Language
)	O
to	O
safely	O
allocate	O
dynamic	B-General_Concept
memory	I-General_Concept
in	O
the	O
RAII	B-Application
paradigm	O
.	O
</s>
<s>
It	O
maintains	O
reference	B-General_Concept
counting	I-General_Concept
ownership	O
of	O
its	O
contained	O
pointer	O
in	O
cooperation	O
with	O
all	O
copies	O
of	O
the	O
.	O
</s>
<s>
Because	O
the	O
implementation	O
of	O
uses	O
reference	B-General_Concept
counting	I-General_Concept
,	O
circular	O
references	O
are	O
potentially	O
a	O
problem	O
.	O
</s>
<s>
The	O
referenced	O
object	O
must	O
be	O
protected	O
separately	O
to	O
ensure	O
thread	B-Operating_System
safety	I-Operating_System
.	O
</s>
<s>
and	O
are	O
based	O
on	O
versions	O
used	O
by	O
the	O
Boost	B-Language
libraries	I-Language
.	O
</s>
<s>
C++	B-Language
Technical	I-Language
Report	I-Language
1	I-Language
(	O
TR1	O
)	O
first	O
introduced	O
them	O
to	O
the	O
standard	O
,	O
as	O
general	O
utilities	O
,	O
but	O
C++11	B-Language
adds	O
more	O
functions	O
,	O
in	O
line	O
with	O
the	O
Boost	B-Language
version	O
.	O
</s>
<s>
There	O
are	O
other	O
types	O
of	O
smart	B-Language
pointers	I-Language
(	O
which	O
are	O
not	O
in	O
the	O
C++	B-Language
standard	O
)	O
implemented	O
on	O
popular	O
C++	B-Language
libraries	O
or	O
custom	O
STL	B-Application
,	O
some	O
examples	O
include	O
hazard	O
pointer	O
and	O
intrusive	O
pointer	O
.	O
</s>
