Skip to content
Permalink
Browse files
Merge pull request #4 from iskhanba/master
Fix typo s/Deference/Dereference
  • Loading branch information
mortennobel committed Nov 19, 2018
2 parents aa0c4b2 + 612312a commit 1c722499d757f18d7254cf9b1d72ef70f4158b9d
Showing with 8 additions and 8 deletions.
  1. +4 βˆ’4 README.md
  2. +4 βˆ’4 cheatsheet-as-sourcefile.cpp
@@ -310,7 +310,7 @@ using namespace N; // Make T visible without N::
shared_ptr<int> x; // Empty shared_ptr to a integer on heap. Uses reference counting for cleaning up objects.
x = make_shared<int>(12); // Allocate value 12 on heap
shared_ptr<int> y = x; // Copy shared_ptr, implicit changes reference count to 2.
cout << *y; // Deference y to print '12'
cout << *y; // Dereference y to print '12'
if (y.get() == x.get()) { // Raw pointers (here x == y)
cout << "Same";
}
@@ -322,8 +322,8 @@ if (y == nullptr) { // Can compare against nullptr (here returns true)
cout << "Empty";
}
y = make_shared<int>(15); // Assign new value
cout << *y; // Deference x to print '15'
cout << *x; // Deference x to print '12'
cout << *y; // Dereference x to print '15'
cout << *x; // Dereference x to print '12'
weak_ptr<int> w; // Create empty weak pointer
w = y; // w has weak reference to y.
if (shared_ptr<int> s = w.lock()) { // Has to be copied into a shared_ptr before usage
@@ -573,4 +573,4 @@ future<int> fut = // result of async function
async(launch::async, fib, 4); // start async function in other thread
// do some other work
cout << fut.get(); // get result of async function. Wait if needed.
```
```
@@ -295,7 +295,7 @@ using namespace N; // Make T visible without N::
shared_ptr<int> x; // Empty shared_ptr to a integer on heap. Uses reference counting for cleaning up objects.
x = make_shared<int>(12); // Allocate value 12 on heap
shared_ptr<int> y = x; // Copy shared_ptr, implicit changes reference count to 2.
cout << *y; // Deference y to print '12'
cout << *y; // Dereference y to print '12'
if (y.get() == x.get()) { // Raw pointers (here x == y)
cout << "Same";
}
@@ -307,8 +307,8 @@ if (y == nullptr) { // Can compare against nullptr (here returns true)
cout << "Empty";
}
y = make_shared<int>(15); // Assign new value
cout << *y; // Deference x to print '15'
cout << *x; // Deference x to print '12'
cout << *y; // Dereference x to print '15'
cout << *x; // Dereference x to print '12'
weak_ptr<int> w; // Create empty weak pointer
w = y; // w has weak reference to y.
if (shared_ptr<int> s = w.lock()) { // Has to be copied into a shared_ptr before usage
@@ -527,4 +527,4 @@ thread t3(pingPongFn, "boing");
future<int> fut = // result of async function
async(launch::async, fib, 4); // start async function in other thread
// do some other work
cout << fut.get(); // get result of async function. Wait if needed.
cout << fut.get(); // get result of async function. Wait if needed.

0 comments on commit 1c72249

Please sign in to comment.