Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include <iostream>
- #include <memory>
- #include <string>
- struct example
- {
- std::string something;
- };
- void tryParseUnique(std::unique_ptr<example> myUnique) // should be similar to example*
- {
- std::printf("%s\n", myUnique->something.c_str());
- }
- void tryParseUniqueRef(std::unique_ptr<example>& myUnique) // should be similar to example*
- {
- std::printf("%s\n", myUnique->something.c_str());
- }
- int main()
- {
- std::unique_ptr<example> myUnique;
- tryParseUnique(myUnique); // compile error
- tryParseUniqueRef(myUnique); // works perfectly
- std::cout << "Hello World!\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement