Back to Basics: Pointers2Back to Basics: Pointers Mike Shah, Ph.D. @MichaelShah | mshah.io | www.youtube.com/c/MikeShah 3:15 pm MDT, Mon. October 25 60 minutes | Introductory Audience 3Abstract Pointers are scary. Unfortunately Unfortunately that previous statement is what many beginners take away when first learning about pointers and the C++ language. In this talk, we will discuss the low level foundations of what a raw pointer 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 | 6 月前3
Back to Basics: Smart PointersSmart Pointers Back to Basics Rainer Grimm Training, Coaching, and Technology Consulting www.ModernesCpp.netSmart Pointer A First Overview std::unique_ptr – Exclusive Ownership std::shared_ptr – Concurrency Function Arguments and Return ValuesOverview 4 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 and0 码力 | 30 页 | 625.43 KB | 6 月前3
Delivering safe C++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 and safer argument passing Stroustrup - C++ safety -CppCon - October 2023 23 Problem: Too many pointers in interfacesLater (1988 – 2011) • Templates • Compile-time selection of implementations • C++20 to 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_ptr0 码力 | 74 页 | 2.72 MB | 6 月前3
Using Modern C++ to Build XOffsetDatastructureXOffsetDatastructure • 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. Fanchen Su, XOffsetDatastructure0 码力 | 111 页 | 3.03 MB | 6 月前3
The Zig Programming Language 0.12.0 Documentationmantissa) IEEE-754- 2008 binary128 bool bool true or false anyopaque void Used for type-erased pointers. void (none) Always the value void{} noreturn (none) the type of break , continue , return , unreachable 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 encoded0 码力 | 241 页 | 7.37 MB | 1 年前3
The Zig Programming Language 0.7.1 DocumentationOptionals undefined String Literals and Character Literals String literals are single-item constant Pointers to null-terminated UTF-8 encoded byte arrays. The type of string literals encodes both the length 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. Character literals have type comptime_int y += 1; ^ const applies to all of the bytes that the identifier immediately addresses. Pointers have their own const-ness. If you need a variable that you can modify, use the var keyword: test0 码力 | 225 页 | 5.74 MB | 1 年前3
Go 101 (Golang 101) v1.21.0Panic/Recover Go Type System §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. first-class citizens. polymorphism through interfaces. value boxing and reflection through interfaces. pointers. function closures. methods. deferred function calls. type embedding. type deduction. memory0 码力 | 630 页 | 3.77 MB | 1 年前3
The Zig Programming Language 0.6.0 DocumentationOptionals undefined String Literals and Character Literals String literals are single-item constant Pointers to null-terminated UTF-8 encoded byte arrays. The type of string literals encodes both the length 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. Character literals have type comptime_int y += 1; ^ const applies to all of the bytes that the identifier immediately addresses. Pointers have their own const-ness. If you need a variable that you can modify, use the var keyword: test0 码力 | 214 页 | 5.37 MB | 1 年前3
The Zig Programming Language 0.4.0 DocumentationLiterals Floating Point Operations Operators Table of Operators Precedence Arrays Vectors SIMD Pointers volatile Alignment allowzero Slices struct extern struct packed struct struct Naming enum extern Optional Type null Optional Pointers Casting Implicit Casts Implicit Cast: Stricter Qualification Implicit Cast: Integer and Float Widening Implicit Cast: Arrays and Pointers Implicit Cast: Optionals Implicit Zero Bit Types Implicit Cast: undefined Explicit Casts Peer Type Resolution Zero Bit Types void Pointers to Zero Bit Types comptime Introducing the Compile-Time Concept Compile-Time Parameters Compile-Time0 码力 | 207 页 | 5.29 MB | 1 年前3
The Zig Programming Language 0.9.1 Documentationmantissa) 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 , 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-facto0 码力 | 234 页 | 7.90 MB | 1 年前3
共 666 条
- 1
- 2
- 3
- 4
- 5
- 6
- 67













