LITERALS SAFELY for Types that Behave as though Built-in - Pablo Halpern - CppCon 2021
EMBRACING USER DEFINED LITERALS SAFELY for Types that Behave as though Built-in Pablo Halpern phalpern@halpernwightsoftware.com CppCon 2021 This work by Pablo Halpern is licensed under a Creative Boolean, pointer, or user-defined type. 10/26/21 Pablo Halpern, 2021 (CC BY 4.0) 4Examples of C++ literals ■ Integer: 123, 456U, 0xfedcba10000LL, 0b1001UL ■ Floating point: 12.3, 4.56e-7F, 2.L ■ Character: 10/26/21 Pablo Halpern, 2021 (CC BY 4.0) 5Contents ✅ What is a literal? ⏹ What are user-defined literals and why do we have them? ⏹ How do you define a new UDL suffix? ⏹ Use cases ⏹ Pitfalls All examples0 码力 | 66 页 | 1.47 MB | 5 月前3Go 101 (Golang 101) v1.21.0
Introduction of Source Code Elements §5. Keywords and Identifiers §6. Basic Types and Their Value Literals §7. Constants and Variables - also introduces untyped values and type deductions. §8. Common Operators may be a large number of values used in programming. Some of them can be represented with their literals (text representations) directly, but others can't. To make programming flexible and less error-prone integer literals. The "Result: " at line 36 is a string literal. Please read basic types and their value literals (§6) for more information about above built-in basic types and their value literals. Some0 码力 | 610 页 | 945.17 KB | 1 年前3Go 101 (Golang 101) v1.21.0
Introduction of Source Code Elements §5. Keywords and Identifiers §6. Basic Types and Their Value Literals §7. Constants and Variables - also introduces untyped values and type deductions. §8. Common Operators may be a large number of values used in programming. Some of them can be represented with their literals (text representations) directly, but others can't. To make programming flexible and less error-prone integer literals. The "Result: " at line 36 is a string literal. Please read basic types and their value literals (§6) for more information about above built-in basic types and their value literals. Some0 码力 | 630 页 | 3.77 MB | 1 年前3Go 101 (Golang 101) v1.21.0
Introduction of Source Code Elements §5. Keywords and Identifiers §6. Basic Types and Their Value Literals §7. Constants and Variables - also introduces untyped values and type deductions. §8. Common Operators may be a large number of values used in programming. Some of them can be represented with their literals (text representations) directly, but others can't. To make programming flexible and less error-prone integer literals. The "Result: " at line 36 is a string literal. Please read basic types and their value literals (§6) for more information about above built- in basic types and their value literals. Some0 码力 | 880 页 | 833.34 KB | 1 年前3Nim 2.0.8 Manual
support nesting too: You can also use the discard statement together with triple quoted string literals to create multiline comments: This was how multiline comments were done before version 0.13.0, keyword property and becomes an ordinary identi�er. Examples String literals Terminal symbol in the grammar: STR_LIT . String literals can be delimited by matching double quotes, and can contain the following terminator. Triple quoted string literals Terminal symbol in the grammar: TRIPLESTR_LIT . String literals can also be delimited by three double quotes """ ... """ . Literals in this form may run for several0 码力 | 132 页 | 5.73 MB | 1 年前3The Zig Programming Language 0.5.0 Documentation
String Literals and Character Literals Escape Sequences Multiline String Literals Assignment undefined Variables Global Variables Thread Local Variables Local Variables Integers Integer Literals Runtime Runtime Integer Values Floats Float Literals Floating Point Operations Operators Table of Operators Precedence Arrays Multidimensional Arrays Vectors SIMD Pointers volatile Alignment allowzero enum extern enum packed enum Enum Literals union Tagged union extern union packed union blocks Shadowing switch Exhaustive Switching Switching with Enum Literals while Labeled while while with Optionals0 码力 | 224 页 | 5.80 MB | 1 年前3The Zig Programming Language 0.7.1 Documentation
allowed for comptime-known values. The type of integer literals. comptime_float (none) Only allowed for comptime-known values. The type of float literals. In addition to the integer types above, arbitrary Optionals 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 string literals converts them to Arrays. Character literals have type comptime_int, the same as Integer Literals. All Escape Sequences are valid in both string literals and character literals. test.zig0 码力 | 225 页 | 5.74 MB | 1 年前3The Zig Programming Language 0.6.0 Documentation
allowed for comptime-known values. The type of integer literals. comptime_float (none) Only allowed for comptime-known values. The type of float literals. In addition to the integer types above, arbitrary Optionals 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 string literals converts them to Arrays. Character literals have type comptime_int, the same as Integer Literals. All Escape Sequences are valid in both string literals and character literals. test.zig0 码力 | 214 页 | 5.37 MB | 1 年前3The Zig Programming Language 0.8.1 Documentation
allowed for comptime-known values. The type of integer literals. comptime_float (none) Only allowed for comptime-known values. The type of float literals. In addition to the integer types above, arbitrary Optionals 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 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 assumed to be UTF-8. Because0 码力 | 234 页 | 6.01 MB | 1 年前3The Zig Programming Language 0.12.0 Documentation
allowed for comptime-known values. The type of integer literals. comptime_float (none) Only allowed for comptime-known values. The type of float literals. In addition to the integer types above, arbitrary Optionals 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 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, any non-ASCII bytes appearing0 码力 | 241 页 | 7.37 MB | 1 年前3
共 967 条
- 1
- 2
- 3
- 4
- 5
- 6
- 97