Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78976173
unique_pointers.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Aug 24, 02:14
Size
405 B
Mime Type
text/x-c
Expires
Mon, Aug 26, 02:14 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
20130565
Attached To
R9360 PCSC_git
unique_pointers.cpp
View Options
#include <iostream>
#include <memory>
std
::
unique_ptr
<
double
>
get_scalar
()
{
// create a unique pointer
return
std
::
make_unique
<
double
>
(
3
);
}
int
main
()
{
std
::
unique_ptr
<
double
>
ptr
=
get_scalar
();
// ... do what I need like...
std
::
cout
<<
*
ptr
;
// no need to delete scalar (will be automatically)
// cannot be copied => compilation error
// std::unique_ptr<double> ptr_copy = ptr;
}
Event Timeline
Log In to Comment