Unraveling string_view: Basics, Benefits, and Best PracticesUnraveling string_view: Basics, Benefits, and Best Practices ## JASMINE LOPEZ & PRITHVI OKADE 20 24 September 15 - 20 ## Topics • Motivation • Performance benefits & basics • string_view: Constructors functions • string vs. string_view and their interoperability • When to use string_view • Using string_view safely • Intro to span • span vs. string_view • Case study of an optimization using string_view function foo which operates on an immutable string. • In C++ we generally will create it with the following signature. 1 void foo(const std::string& str); string existing_str; foo(existing_str); foo("hello0 码力 | 61 页 | 1.11 MB | 1 年前3
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 ## literal [ lit-er-uhl ] ## adjective 1. in accordance that represents a value of an integer, floating-point, character, string, Boolean, pointer, or user-defined type. ## Examples of C++ literals ■ Integer: 123, 456U, 0xfedcba10000LL, 0b1001UL ☑ Floating point: point: 12.3, 4.56e-7F, 2.L ■ Character: 'a', L'b', u'c', U'd' ■ String: "hello", L"goodbye", u8"see", u"you", U"later." ■ Boolean:0 码力 | 66 页 | 1.47 MB | 1 年前3
Nim Tutorial (Part I) 0.17.1Contents 1 Introduction 2 2 The first program 2 3 Lexical elements 2 3.1 String and character literals 3 3.2 Comments 3 3.3 Numbers 3 4 The var statement 3 5 The assignment statement "hello world" program: # This is a comment echo "What's your name?" var name: string = readLine(stdin) echo "Hi, ", name, "!" Save this code to the file "greetings with spaces only, tabulators are not allowed. String literals are enclosed in double quotes. The var statement declares a new variable named name of type string with the value that is returned by the readLine0 码力 | 24 页 | 271.23 KB | 1 年前3
C++高性能并行编程与优化 - 课件 - 15 C++ 系列课:字符与字符串1. vector 容器初体验 & 迭代器入门 (BV1qF411T7sd) 2. 你所不知道的 set 容器 & 迭代器分类 (BV1m34y157wb) 3. string, string_view, const char * 的爱恨纠葛(本期) 4. 万能的 map 容器全家桶及其妙用举例 5. 函子 functor 与 lambda 表达式知多少 6. 通过实战案例来学习 ~/Codes/course/15 (master) $ 你的 char 是有符号的,我猜你是 x86 架构 ## C 语言中的字符串 • 字符串 (string) 就是由字符 (character) 组成的数组。 • C 语言中,字符串用双引号 “” 包裹,字符用单引号 “” 包裹。 • char c = 'h'; • char ## 封装的 std::string 应运而生 10 #include9 #include <string> 8 7 using namespace std; 6 5 int main() { 4 string s1 = "hello"; 3 string s2 = "world"; 2 string s3 = s1 + s2; 0 码力 | 162 页 | 40.20 MB | 2 年前3
Nim 2.0.8 Manualstatements / simpleStmt # or a simple statement ## Comments Comments start anywhere outside a string or character literal with the hash character #. Comments consist of a concatenation of comment pieces documentation comment here. ]## You can also use the discard statement together with triple quoted string literals to create multiline comments: discard "" You can have any Nim code text commented out html#writing-unitems) test framework. ## I dentifiers & Keywords Identifiers in Nim can be any string of letters, digits and underscores, with the following restrictions: • begins with a letter does0 码力 | 132 页 | 5.73 MB | 1 年前3
Kotlin language specification
Version 1.9-rfc+0.1'crossinline' REIFIED: 'reified' EXPECT: 'expect' ACTUAL: 'actual' #### 1.2.3 Literals DecDigitNoZero: '1' | '2' | '3' | '4' | '5' | '6' valid property declaration in Kotlin: val field = 2 even though field is a keyword #### 1.2.5 String mode grammar $ QUOTE\_OPEN $ TRIPLE QUOTE OPEN FieldIdentifier '$\$$ IdentifierOrSoftKey IdentifierOrSoftKey Opening a double quote ( QUOTE_OPEN ) rule puts the lexical grammar into the special “line string” mode with the following rules. Closing double quote ( QUOTE_CLOSE ) rule exits this mode. QUOTE_CLOSE0 码力 | 38 页 | 358.59 KB | 2 年前3
Julia v1.4.2 Documentation14.2 String Basics 63 14.3 Unicode and UTF-8 65 14.4 Concatenation 68 14.5 Interpolation 69 14.6 Triple-Quoted String Literals 70 14.7 Common Operations 72 14.8 Non-Standard String Literals .. 73 14.9 Regular Expressions ..... 73 14.10 Byte Array Literals ..... 78 14.11 Version Number Literals ..... 79 14.12 Raw String Literals ..... 80 15 Functions ..... 81 15.1 Argument Passing macro 227 Hygiene 229 Macro and dispatch 231 25.4 Code Generation 231 25.5 Non-Standard String Literals 232 25.6 Generated functions 234 An advanced example 238 Optionally-generated functions0 码力 | 1314 页 | 4.29 MB | 2 年前3
Fast and small C++the program name. $ ./a.out Hello, C++! • <string> stands for a header file with the name string • [[xyz]] marks a C++ attribute with the name xyz.string> ## fertig adjective /ˈfɛrtɪç/ finished ready the Small String Optimization struct string { size_t mSize(); size_t mCapacity(); char* mData(); char mSSOBuffer[16]; bool mIsSSO{true}; }; static_assert(sizeof(string) == 48); 6ad37b/p9_2.jpg) Andreas Fertig ## I mplementing the Small String Optimization - libstdc++ struct string { char* mPtr; size_t mSize(); union { size_t mCapacity;0 码力 | 17 页 | 790.91 KB | 1 年前3
Regular, Revisitedrequirements for its data structures and algorithms to work properly. STL vocabulary types such as string_view, span, optional, expected etc., raise new questions regarding values types, whole-part semantics understand and use). The C++ built-in types are regular, and so are standard-library classes such as string, vector, and map. Concrete classes without assignment and equality can be defined, but they are types. This analysis provides us some basis to evaluate non-owning reference parameters types (like string_view and span) in a practical fashion, without discarding Regular design. Let's go back to the0 码力 | 180 页 | 19.96 MB | 1 年前3
TypeScript 类型系统flag = false; // 字符串类型 let str: string; str = 'Hello World'; ## TypeScript 高级类型 // 数组类型 let arr: number]; arr = [1, 2, 3, 4]; // 接口 interface Person { name: string; age: number; } let p1: => { console.log('callback'); }; ## TypeScript 高级类型 // 交叉类型 type User1 = { name: string; age: number }; type User2 = { sex: number } const user: User1 & User2 = { name: '6' | '7' | '8' | '9'; // 元组类型 let pair: [string, number] = ['xxxx', 2]; let triple: [string, number, boolean] = ['yyyy', 1, false]; ## TypeScript 高级类型 //0 码力 | 25 页 | 1.27 MB | 2 年前3
共 1000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 100
相关搜索词
string_viewstd::stringspan性能优化内存分配用户定义字面量内置类型字面量操作符C++17类型行为Nimvar statementprocstring literalscontrol flowC字符串小字符串优化vectorGuardsLocksModule systemIdentifiersString typeKotlin language specificationannotationslexicallymultiline stringidentifierDocumentation systemREPLCore modulesString functionsModulesSmall String Optimizationconstexprtemplatestruct压缩对联结Regular typesSTLC++void类型unknown类型never类型number类型string类型













