Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F90341365
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
Thu, Oct 31, 17:20
Size
405 B
Mime Type
text/x-c
Expires
Sat, Nov 2, 17:20 (2 d)
Engine
blob
Format
Raw Data
Handle
22055593
Attached To
R7571 SP4E-TB-TL-FR
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