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 | 2 年前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
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
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
Java 应用与开发 - Java 数组和字符串学习目标 1. 掌握 Java 数组的概念 2. 学会一维数组和二维数组的使用,认识 Arrays 类,掌握操 作数组相关方法 3. 掌握 Java 有 的概念,字符串与数组的关系;学会 String 类 闻符串操作方法 大网 数组的概念 和 Ooo 数组的概念 一维数组 二维数组 宝 值的方法,实 字符串内容。 类实现。 的。String 类每一个看起来会修改 :际上都创建了一个新的对象,以包含修 String s = new String("hello java"); stoUpperCase(); System.out .println(s); 字符中 oosooooooooo 理解 Java 字符串 CODE String.java Part 1 1 public public final class String 2 implements java.io.Serializable,Comparable<String>,CharSequence { [AT 3 LAz Te ualue is used Jor character storage,w/ 全 Private final char value[]; /V2 6 [xz0 码力 | 33 页 | 620.46 KB | 2 年前3
C++23: An Overview of Almost All New and Updated FeaturesLibrary String Formatting Improvements Standard Library Modules std::flat_(multi)map / std::flat_(multi)set std::mdspan std::generator basic_string(_view):contains() • Construct string(_view) From From nullptr basic_string::resize_and_overwrite() Monadic Operations for std::optional • Stacktrace Library • Changes to Ranges Library • Changes to Views Library std::expected std::move_only_function<> Library String Formatting Improvements Standard Library Modules std::flat_(multi)map / std::flat_(multi)set std::mdspan std::generator basic_string(_view):contains() • Construct string(_view) From0 码力 | 105 页 | 759.96 KB | 1 年前3
共 1000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 100
相关搜索词
string_viewstd::stringspan性能优化内存分配用户定义字面量内置类型字面量操作符C++17类型行为Nimvar statementprocstring literalscontrol flowC字符串小字符串优化vectorKotlin language specificationannotationslexicallymultiline stringidentifierSmall String Optimizationconstexprtemplatestruct压缩对联结Regular typesSTLC++void类型unknown类型never类型number类型string类型数组字符串String类Arrays类不可变性Explicit Object ParametersString Formatting Improvementsstd::mdspanstd::generatorstd::expected













