Customizing Compilation Error MessagesSecurity Insights reflect Public Q Go to file main 1 Branch 16 Tags Edit Pins ☐ Watch 10 ☐ Fork 14 ★ Starred 271 krzysztof-jusiak [README] Add file [README] README.md -> reflect [README] Code cpp20 reflect 2 months ago Readme 3 weeks ago Activity Custom properties ☐ : ☆ 271 stars 10 watching // Overview / Examples / API / FAQ 14 forks Report repository ## REFLECT: C++20 Static guarantees no UB, no memory leaks* • Single header (https://raw.githubusercontent.com/qlibs/reflect/main/reflect - for integration see FAQ) v1.2.3 Latest 3 weeks ago • Compiles cleanly with (-fno-exceptions0 码力 | 12 页 | 1.47 MB | 1 年前3
Go 101 (Golang 101) v1.21.0Type-Unsafe Pointers ☐ §26. Generics - use and read composite types ☐ §27. Reflections - the reflect standard package. ## • Some Special Topics §28. Line Break Rules §29. More About Deferred Function share all (underlying) elements. Appending elements into (or deleting elements from) one map will reflect on the other map. Like map assignments, if a slice is assigned to another slice, they will share equal to each other. However, if the length/capacity of one slice changes later, the change will not reflect on the other slice. When an array is assigned to another array, all the elements are copied from0 码力 | 610 页 | 945.17 KB | 2 年前3
Go 101 (Golang 101) v1.21.0§25. Type-Unsafe Pointers §26. Generics - use and read composite types ☐ §27. Reflections - the reflect standard package. ## • Some Special Topics §28. Line Break Rules §29. More About Deferred Function share all (underlying) elements. Appending elements into (or deleting elements from) one map will reflect on the other map. Like map assignments, if a slice is assigned to another slice, they will share equal to each other. However, if the length/capacity of one slice changes later, the change will not reflect on the other slice. When an array is assigned to another array, all the elements are copied from0 码力 | 630 页 | 3.77 MB | 2 年前3
Go 101 (Golang 101) v1.21.0§25. Type-Unsafe Pointers o §26. Generics - use and read composite types §27. Reflections - the reflect standard package. ## • Some Special Topics §28. Line Break Rules §29. More About Deferred Function share all (underlying) elements. Appending elements into (or deleting elements from) one map will reflect on the other map. Like map assignments, if a slice is assigned to another slice, they will share equal to each other. However, if the length/capacity of one slice changes later, the change will not reflect on the other slice. When an array is assigned to another array, all the elements are copied from0 码力 | 880 页 | 833.34 KB | 2 年前3
Golang 101(Go语言101 中文版) v1.21.a通过包裹不同具体类型的非接口值来实现反射和多态 - 第24章:类型内嵌 - 不同于继承的类型扩展方式 - 第25章:非类型安全指针 第26章:泛型 - 如何使用和解读组合类型 。第27章:反射 - reflect 标准库包中提供的反射支持 ## • 一些专题 第28章:代码断行规则 。第29章:更多关于延迟函数调用的知识点 。第30章:一些恐慌/恢复用例 。第31章:详解panic/recover原理 "reflect" ) func main() { s := make([]int, 2, 6) fmt.Println(len(s), cap(s)) // 2 6 reflect.ValueOf(&s).Elem().SetLen(3) fmt.Println(len(s), cap(s)) // 3 6 reflect.ValueOf(&s) ValueOf(&s).Elem().SetCap(5) fmt.Println(len(s), cap(s)) // 3 5 } 传递给函数reflect.SetLen调用的第二个实参值必须不大于第一个实参切片值的容量。传递给函数reflect.SetCap调用的第二个实参值必须不小于第一个实参切片值的长度并且须不大于第一个实参切片值的容量。否则,在运行时刻将产生一个恐慌。 此反射方法的效率很低,远低于一个切片的赋值。0 码力 | 608 页 | 1.08 MB | 2 年前3
阮一峰 《ECMAScript 6入门》 第三版函数的扩展 1.8 数组的扩展 1.9 对象的扩展 1.10 Symbol 1.11 Set 和 Map 数据结构 1.12 Proxy 1.13 Reflect 1.14 Promise 对象 1.15 Iterator 和 for...of 循环 1.16 Generator 函数的语法 1.17 Generator 函数的异步应用 getOwnPropertySymbols(obj) Object.getOwnPropertySymbols 返回一个数组,包含对象自身的所有 Symbol 属性。 ### (5) Reflect.ownKeys(obj) Reflect.ownKeys 返回一个数组,包含对象自身的所有属性,不管属性名是 Symbol 或字符串,也不管是否可枚举。 以上的5种方法遍历对象的属性,都遵守同样的属性遍历的次序规则。 最后遍历所有属性名为 Symbol 值的属性,按照生成时间排序。 Reflect.ownKeys({ [Symbol()]:0, b:0, 10:0, 2:0, a:0 }) // ['2', '10', 'b', 'a', Symbol()] 上面代码中, Reflect.ownKeys 方法返回一个数组,包含了参数对象的所有属性。这0 码力 | 679 页 | 2.66 MB | 2 年前3
Golang 101(Go语言101 中文版) v1.21.a。第23章:接口-通过包裹不同具体类型的非接口值来实现反射和多态 第24章:类型内嵌-不同于继承的类型扩展方式 第25章:非类型安全指针 第26章:泛型-如何使用和解读组合类型 。第27章:反射 - reflect 标准库包中提供的反射支持 ## • 一些专题 第28章:代码断行规则 。第29章:更多关于延迟函数调用的知识点 。第30章:一些恐慌/恢复用例 。第31章:详解panic/recov import ( 4| "fmt" 5| "reflect" 6| ) 7| 第18章:数组、切片和映射 8| func main() { 9| s := make([]int, 2, 6) 10| fmt.Println(len(s), cap(s)) // 2 6 11| 12| reflect.ValueOf(&s).Elem().SetLen(3) 13| Println(len(s), cap(s)) // 3 6 14| 15| reflect.ValueOf(&s).Elem().SetCap(5) 16| fmt.Println(len(s), cap(s)) // 3 5 17| } 传递给函数 reflect.SetLen 调用的第二个实参值必须不大于第一个实参切片值的容量。传递给函数 reflect.SetCap 调用的第二个实参值必须不小于第一个实参0 码力 | 591 页 | 21.40 MB | 2 年前3
Golang 101(Go语言101 中文版) v1.21.a通过包裹不同具体类型的非接口值来实现反射和多态 - 第24章:类型内嵌 - 不同于继承的类型扩展方式 - 第25章:非类型安全指针 第26章:泛型 - 如何使用和解读组合类型 。第27章:反射 - reflect 标准库包中提供的反射支持 ## • 一些专题 第28章:代码断行规则 第29章:更多关于延迟函数调用的知识点 第30章:一些恐慌/恢复用例 。第31章:详解panic/recover原理 2| 3| import ( 4| "fmt" 5| "reflect" 6| ) 7| 8| func main() { 9| s := make([]int, 2, 6) 10| | fmt.Println(len(s), cap(s)) // 2 6 11| | 12 | reflect.ValueOf(&s).Elem().SetLen(3) 13 | fmt Println(len(s), cap(s)) // 3 6 14 | | reflect.ValueOf(&s).Elem().SetCap(5) 16 | fmt.Println(len(s), cap(s)) // 3 5 17 | } 传递给函数 reflect.SetLen 调用的第二个实参值必须不大于第一个实参切片值的容量。传递给函数 reflect.SetCap 调用的第二个实参值必须不小于第一个实0 码力 | 821 页 | 956.82 KB | 2 年前3
2.1.6 谈谈 Go 泛型layers ’ alt=‘OCR图片’/> 适合用reflect的场景 encode/json switch t.Kind() { case reflect.Bool: return boolEncoder case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: return intEncoder intEncoder case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uintptr: return uintEncoder case reflect.Float32: return float32Encoder case reflect.Float64: float64Encoder case reflect.String: return stringEncoder case reflect.Interface: return interfaceEncoder case reflect.Struct: return newStructEncoder(t) case reflect.Map: return newMapEncoder(t)0 码力 | 52 页 | 3.09 MB | 1 月前3
1.6 Go并发编程实践 - 晁岳攀> 64<<10 { return } p.buf = p.buf[:0] p.arg = nil p.value = reflect.Value{} ppFree.Put(p) } ’ alt=‘OCR图片’/> 基本同步原语 Pool 禁止游泳 json包错误使用 go#27735 func putEncodeState(e cases []reflect.SelectCase for _, c := range channels { cases = append(cases, reflect.SelectCase{ Dir: reflect.SelectRecv, Chan: reflect.ValueOf(c) ValueOf(c), }) } reflect.Select(cases) }() return orDone } ’ alt=‘OCR图片’/> Channel Fan-in 递归 func fanInRec(chans …<-chan interface{}) <-chan interface{} { switch0 码力 | 82 页 | 16.62 MB | 1 月前3
共 1000 条
- 1
- 2
- 3
- 4
- 5
- 6
- 100













