C++高性能并行编程与优化 - 课件 - 15 C++ 系列课:字符与字符串C++ 的 vector 采用了 [ptr, ptr + len, ptr + capacity] 构型。 vector 没有采用小字符串优化…这是因为 string 面对的都 是 char , wchar_t 这种比较小的类型,且用户常用的字符 串往往比较短很容易放进 15 字节的局部栈空间里;然而 vector 面对的往往是比较大的数据结构,有时还有智能指 针, std::thread 这种具有非平凡构造 表示这么宽的字符?有很多种解决方案。 • 一种方案是:索性放弃 char ,改用 wchar_t 做字符类型 。 • wchar_t 在 Linux 上为 4 字节,完全足够表示 Unicode 这 0x000000~0x10FFFF 的范围,甚至还有 1 字节浪费 。 wchar_t 的普及 • 所以他们提议:以后用 const wchar_t * 代替 const char * 。 • 或者继续用 组。并且现在 ‘ \0’ 也不能用作结束符了,因为 wchar_t 的最高位始终 0 (因为 Unicode 只有 3 字节, wchar_t 的 4 字节有一个字节总是为 0 的),这会导致现有的 C 语言函数用不了,例如 strlen(s) 现在总是会返回 3 了。 • 因此 C 语言为了适应这个变化,推出了专门针对 wchar_t 的 wcslen 、 wcscpy 、 wmemset0 码力 | 162 页 | 40.20 MB | 1 年前3
现代C++ 教程:高速上手C++11/14/17/20double、const char *、模板字面量算符; 3. 字符串字面量:必须使用 (const char *, size_t) 形式的参数表; 4. 字符字面量:参数只能是 char, wchar_t, char16_t, char32_t 这几种类型。 9.4 内存对齐 C++ 11 引入了两个新的关键字 alignof 和 alignas 来支持对内存对齐进行控制。alignof 关键字0 码力 | 83 页 | 2.42 MB | 1 年前3
Julia 中文文档arm) long Clong Int (UNIX), Int32 (Windows) unsigned long Culong UInt (UNIX), UInt32 (Windows) wchar_t Cwchar_t Int32 (UNIX), UInt16 (Windows) Note When calling Fortran, all inputs must be passed by Vector{T}. Warning Julia’s Char type is 32 bits, which is not the same as the wide character type (wchar_t or wint_t) on all platforms. Warning A return type of Union{} means the function will not return use this for functions that return no value (void) but do return, use Cvoid instead. Note For wchar_t* arguments, the Julia type should be Cwstring (if the C routine expects a NUL- terminated string)0 码力 | 1238 页 | 4.59 MB | 1 年前3
共 3 条
- 1













