-
## +21
## Back to Basics: Pointers
## MIKE SHAH 2021 October 24-29
## Please do not redistribute slides without prior permission
## Back to Basics: Pointers
Mike Shah, Ph.D.
@MichaelShah | mshah.io and enticed you to join me is here!
Pointers are scary. Unfortunately that previous statement is what many beginners take away when first learning about pointers and the C++ language. In this talk, we examples of raw pointers for creating data structures, passing data into functions, dynamically allocated arrays, and function pointers. This portion will cover capabilities of raw pointers and syntax: $
0 码力 |
152 页 |
5.61 MB
| 1 年前 3
-
nt max()
std::cout
# Smart Pointers
std::cout
## Back to Basics
d(std::logical
std::cout << "myVec::";
for (auto i: myVec).std::cout
std::cout << "\n";
std::vector Concurrency
Function Arguments and Return Values
## Overview
Smart pointers automatically manage the lifetime of its resource.
## ■ Smart Pointers
■ Allocate und deallocate their resource in the constructor the lifetime of its resource.
## ■ std::unique ptr
Is the replacement for the deprecated Smart Pointers std::auto ptr
→ std::unique_ptr doesn't support copy semantic
- Can be used in the containers
0 码力 |
30 页 |
625.43 KB
| 1 年前 3
-
## +23
## Lock-free Atomic Shared Pointers Without a Split Reference Count? It Can Be Done!
DANIEL ANDERSON

Daniel Anderson and what it is used for
• You’ve heard of shared_ptr
Things we won't cover
• Alias pointers, weak pointers
Carnegie Mellon University
## What we'll learn today
• How shared ptr and what it is used for
• You’ve heard of shared ptr
Things we won't cover
• Alias pointers, weak pointers
Carnegie Mellon University
## Why is this important?

o 11.2. scanf()
• 12. Variables pointer to the first element of the array, and as such can be used like a normal pointer.
More on pointers soon.
### 8. Strings
In C, strings are one special kind of array: a string is an array of char of two strings
• strlen() to calculate the length of a string
and many, many more.
### 9. Pointers
Pointers are one of the most confusing/challenging parts of C, in my opinion. Especially if you are
0 码力 |
60 页 |
908.68 KB
| 2 年前 3
-
jpg)
# Six ways for Implementing Math Expressions Calculator
A walk through polymorphism, smart pointers, templates, concepts and more
Amir Kirsh

Pointers / References are not mandatory for Polymorphism!
- Prefer using smart pointers for internal members
- Try to hide your smart pointers, exposing value type semantics
0 码力 |
63 页 |
1.85 MB
| 1 年前 3
-
in-range (often a run-time check)
## • That
• Implies range checking and elimination of dangling pointers (“memory safety”)
• Is just what C++ requires
• Is what most programmers have tried to ensure Encapsulation
• Well-defined interfaces
• Classes
• Abstract base classes
## Problem: Too many pointers in interfaces

fiddle with arrays (and pointers)
• Enable range checking
## • Algorithms
• C++98: sort(begin(v), end(v))
• C++20: sort(v)
• “smart pointers” (resource management pointers)
• unique_ptr, shared_ptr
0 码力 |
74 页 |
2.72 MB
| 1 年前 3
-
XOffsetDatastructure
• X + Offset + Datastructure
• Offset
• Offset-based Pointers
• Memcopyable
// We use Offset-based pointers instead of raw pointers. This approach allows us to create data structures that are XOffsetDatastructure
• X + Offset + Datastructure
• Offset
• Offset-based Pointers
• Memcopyable
// We use Offset-based pointers instead of raw pointers. This approach allows us to create data structures that are structure.
- As shown in the diagram on the right, the lines connecting different elements represent Pointers and References, which is designed with Time and Space considerations.
 | Always the value void{} |
noreturn undefined
## String Literals and Unicode Code Point Literals
String literals are constant single-item Pointers to null-terminated byte arrays. The type of string literals encodes both the length, and the fact fact that they are null-terminated, and thus they can be coerced to both Slices and Null-Terminated Pointers. Dereferencing string literals converts them to Arrays.
Because Zig source code is UTF-8 encoded 0 码力 |
241 页 |
7.37 MB
| 2 年前 3 -
mantissa) IEEE-754-2008 binary128|
|bool|bool|true or false|
|anyopaque|void|Used for type-erased pointers.|
|void|(none)|0 bit type|
|noreturn|(none)|the type of break, continue, return, unreachable, and undefined
## String Literals and Unicode Code Point Literals
String literals are constant single-item Pointers to null-terminated byte arrays. The type of string literals encodes both the length, and the fact fact that they are null-terminated, and thus they can be coerced to both Slices and Null-Terminated Pointers. Dereferencing string literals converts them to Arrays.
The encoding of a string in Zig is de-facto 0 码力 |
234 页 |
7.90 MB
| 2 年前 3 -
• Go Type System
o §14. Go Type System Overview - a must read to master Go programming.
。§15. Pointers
§16. Structs
§17. Value Parts - to gain a deeper understanding into Go values.
§18. Arrays, Slices reflection and polymorphism.
☐ §24. Type Embedding - type extension in the Go way.
☐ §25. Type-Unsafe Pointers
§26. Generics - use and read composite types
☐ §27. Reflections - the reflect standard package citizens.
• polymorphism through interfaces.
• value boxing and reflection through interfaces.
• pointers.
• function closures.
• methods.
• deferred function calls.
• type embedding.
• type deduction 0 码力 |
630 页 |
3.77 MB
| 2 年前 3
|