Reflection Based Libraries to Look Forward Towrapped copy Attributes: x <__main__.MyClass object at 0x7f1a9 1 2 3 4 5 6 7 8 9 10 11 13GoLang 14Golang is a compiled but duck-typed language Well, structurally typed, but close enough Runtime compile time constructs Provides a package reflect to get “reflection values”. Reflecting GoLang 15Reflecting GoLang type T struct { A string B int } t := T{"CppCon!", 24} s := reflect.ValueOf(&t) the type Customizing the default behavior *mentioned in P2911 52One of my favorite features from Golang Adding information at the point of definition Has its place, as opposed to adding code at the time0 码力 | 118 页 | 14.33 MB | 6 月前3
Modern C++ Tutorial: C++11/14/17/20 On the Fly. . . . . . . . . . . . . . . . . . . . . . . 54 Basic Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 Runtime Indexing . . . . . . . . . . . . . . . "capacity:" << v.capacity() << std::endl; // output 4 // The auto-expansion logic here is very similar to Golang's slice. v.push_back(4); v.push_back(5); std::cout << "size:" << v.size() << std::endl; // output return std::make_tuple(2.9, 'C', "Jack"); if (id == 2) return std::make_tuple(1.7, 'D', "Ive"); 54 4.3 Tuples CHAPTER 04 CONTAINERS // it is not allowed to return 0 directly // return type is std::tuple0 码力 | 92 页 | 1.79 MB | 1 年前3
现代C++ 教程:高速上手C++11/14/17/203 std::unique_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 5.4 std::weak_ptr . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . std::cout << "capacity:" << v.capacity() << std::endl; // 输出 4 46 4.1 线性容器 第 4 章容器 // 这里的自动扩张逻辑与 Golang 的 slice 很像 v.push_back(4); v.push_back(5); std::cout << "size:" << v.size() << std::endl; // 输出 既然是独占,换句话说就是不可复制。但是,我们可以利用 std::move 将其转移给其他的 unique_ptr,例如: #include#include struct Foo { 54 5.4 std::weak_ptr 第 5 章智能指针与内存管理 Foo() { std::cout << "Foo::Foo" << std::endl; } ~Foo() { std::cout 0 码力 | 83 页 | 2.42 MB | 1 年前3
Hello 算法 1.0.0b2 C++版list = { 1, 3, 2, 5, 4 }; 访问与更新元素。列表的底层数据结构是数组,因此可以在 ?(1) 时间内访问与更新元素,效率很高。 4. 数组与链表 hello‑algo.com 54 // === File: list.cpp === /* 访问元素 */ int num = list[1]; // 访问索引 1 处的元素 /* 更新元素 */ list[1] = 0; 1.8 之后,HashMap 内数组长度大于 64 时,长度大于 8 的链 表会被转化为「红黑树」,以提升查找性能。 Python 采用「开放寻址」。字典 dict 使用伪随机数进行探测。 Golang 采用「链式地址」。Go 规定每个桶最多存储 8 个键值对,超出容量则连接一个溢出桶; 当溢出桶过多时,会执行一次特殊的等量扩容操作,以保证性能。 6.3. 小结 ‧ 向哈希表中输入一个键 key0 码力 | 197 页 | 15.72 MB | 1 年前3
Hello 算法 1.0.0b4 C++版内存浪费:我们可以初始化一个比较长的数组,只用前面一部分,这样在插入数据时,丢失的末尾元素 都是我们不关心的,但这样做同时也会造成内存空间的浪费。 4. 数组与链表 hello‑algo.com 54 4.1.3. 数组常用操作 数组遍历。以下介绍两种常用的遍历方法。 // === File: array.cpp === /* 遍历数组 */ void traverse(int *nums 1.8 以来,当 HashMap 内数组长度达到 64 且链表长度达到 8 时,链表会被转 换为红黑树以提升查找性能。 Python 采用开放寻址。字典 dict 使用伪随机数进行探测。 Golang 采用链式地址。Go 规定每个桶最多存储 8 个键值对,超出容量则连接一个溢出桶;当溢出桶过多时, 会执行一次特殊的等量扩容操作,以确保性能。 6.3. 哈希算法 在上两节中,我们了解了哈0 码力 | 343 页 | 27.39 MB | 1 年前3
Hello 算法 1.0.0b5 C++版3 数字编码 * � 在本书中,标题带有的 * 符号的是选读章节。如果你时间有限或感到理解困难,可以先跳过, 等学完必读章节后再单独攻克。 第 3 章 数据结构 hello‑algo.com 54 3.3.1 原码、反码和补码 在上一节的表格中我们发现,所有整数类型能够表示的负数都比正数多一个,例如 byte 的取值范围是 [−128, 127] 。这个现象比较反直觉,它的内在原因涉及到原码、反码、补码的相关知识。 1.8 以来,当 HashMap 内数组长度达到 64 且链表长度达到 8 时,链表会被转 换为红黑树以提升查找性能。 Python 采用开放寻址。字典 dict 使用伪随机数进行探测。 Golang 采用链式地址。Go 规定每个桶最多存储 8 个键值对,超出容量则连接一个溢出桶;当溢出桶过多时, 会执行一次特殊的等量扩容操作,以确保性能。 6.3 哈希算法 在上两节中,我们了解了哈希0 码力 | 377 页 | 30.69 MB | 1 年前3
Conan 1.36 Documentationpackage. It assumes that the binary will be affected by the direct dependencies, which they will already 54 Chapter 6. Creating Packages Conan Documentation, Release 1.36.0 encode how their transitive dependencies "ref": "pkgb/0.1@user/testing", "options": "shared=False", "package_id": "2418b211603ca0a3858d9dd1fc1108d54a4cab99", "prev": "0", "modified": true, "requires": ["1"], "context": "host" } ... } Note that some build_release && cd build_release $ conan install .. --profile=gcc54release $ cd .. && mkdir build_debug && cd build_debug $ conan install .. --profile=gcc54debug $ cd .. $ conan info . --install-folder=build_release0 码力 | 765 页 | 5.71 MB | 1 年前3
Conan 1.37 DocumentationRecipe and Sources in the Same Repo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 i 7.4 Packaging Existing Binaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . dst="lib", keep_path=False) self.copy("*.dll", dst="bin", keep_path=False) (continues on next page) 54 Chapter 7. Creating Packages Conan Documentation, Release 1.37.2 (continued from previous page) "ref": "pkgb/0.1@user/testing", "options": "shared=False", "package_id": "2418b211603ca0a3858d9dd1fc1108d54a4cab99", "prev": "0", "modified": true, "requires": ["1"], "context": "host" } ... } Note that some0 码力 | 793 页 | 6.98 MB | 1 年前3
Conan 1.38 DocumentationRecipe and Sources in the Same Repo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 i 7.4 Packaging Existing Binaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . dst="lib", keep_path=False) self.copy("*.dll", dst="bin", keep_path=False) (continues on next page) 54 Chapter 7. Creating Packages Conan Documentation, Release 1.38.0 (continued from previous page) "ref": "pkgb/0.1@user/testing", "options": "shared=False", "package_id": "2418b211603ca0a3858d9dd1fc1108d54a4cab99", "prev": "0", "modified": true, "requires": ["1"], "context": "host" } (continues on next0 码力 | 809 页 | 7.02 MB | 1 年前3
Conan 1.39 DocumentationRecipe and Sources in the Same Repo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 i 7.4 Packaging Existing Binaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . dst="lib", keep_path=False) self.copy("*.dll", dst="bin", keep_path=False) (continues on next page) 54 Chapter 7. Creating Packages Conan Documentation, Release 1.39.0 (continued from previous page) "ref": "pkgb/0.1@user/testing", "options": "shared=False", "package_id": "2418b211603ca0a3858d9dd1fc1108d54a4cab99", "prev": "0", "modified": true, "requires": ["1"], "context": "host" } (continues on next0 码力 | 819 页 | 7.05 MB | 1 年前3
共 220 条
- 1
- 2
- 3
- 4
- 5
- 6
- 22













