摘要:
原文 @safe void check() { int random; auto createGenerator() { int* p = &random; return p; } scope gen = createGenerator; } 它确实编译成功.两者都应成功编译,因为结构只是指针的包装 阅读全文
posted @ 2022-08-11 15:29
zjh6
阅读(16)
评论(0)
推荐(0)
摘要:
原文 shared TT[] a; T processArray(T)(ref T[] p){/*...*/} //函数在参数上调用`.保留`.意思是`void`为函数`返回类型` a.processArray; //不能从`!()(shared(T[]))`推导. 即使更改函数为仅接受共享参数,. 阅读全文
posted @ 2022-08-11 10:23
zjh6
阅读(22)
评论(0)
推荐(0)
摘要:
原文 测试用例: shared int[int] aa; void main () { cast()aa[1] = 1;//违反区间 } 原来工作正常. 你正在aa[1]上抛弃共享.该表达式是访问值,而不是赋值.与定义opIndex和opIndexAssign的结构(表达式调用opIndex,而不是 阅读全文
posted @ 2022-08-11 09:39
zjh6
阅读(24)
评论(0)
推荐(0)
摘要:
alias ir = inclusiveRange; auto inclusiveRange(T = int)(T f = T(0), T l = T(0), T s = T(1)) { if(!l) { l = f; f = 0; } return InclusiveRange!T(f, l, s 阅读全文
posted @ 2022-08-11 08:54
zjh6
阅读(12)
评论(0)
推荐(0)
摘要:
借助脚本变量来保存. fun! Ts() let i=win_getid() call Sgid(i) echo Ggid() endf Sgid(i)里面只是一个脚本变量而已.通过Ggid()来返回.同样,可以通过脚本变量在窗口间传值! 可任意传数据: fun! Ts() let i= [2,4, 阅读全文
posted @ 2022-08-10 20:56
zjh6
阅读(18)
评论(0)
推荐(0)
摘要:
let window_count = winnr('$') let prev_window = winnr('#') 阅读全文
posted @ 2022-08-10 20:29
zjh6
阅读(17)
评论(0)
推荐(0)
摘要:
原文 pure @nogc @safe BigInt opAssign(T : BigInt)(T x); //上下有何差别? pure @nogc @safe BigInt opAssign(BigInt x); 是的,这种语法允许任何隐式转换为BigInt;例如: import std.bigi 阅读全文
posted @ 2022-08-10 09:06
zjh6
阅读(13)
评论(0)
推荐(0)
摘要:
原文 永远不要使用__gshared.这是明显安全漏洞.改为使用shared. 如果使用时遇见shared的编译错误,那是编译器在警告你.应该认真考虑线程安全,然后才在正确的位置抛弃shared. 使用__gshared,编译器假装没有看到变量是共享的.并除非仔细思考,保证会生成竞争. 顺便,有优先 阅读全文
posted @ 2022-08-09 11:17
zjh6
阅读(60)
评论(0)
推荐(0)
摘要:
原文 { import core.memory: GC; GC.disable(); scope(exit) GC.enable(); foreach (...) // 热代码. } void load_assets() { import core.memory: GC; // 分配,加载等. GC 阅读全文
posted @ 2022-08-09 08:17
zjh6
阅读(7)
评论(0)
推荐(0)
摘要:
原文 struct TestArray(ulong element_n) { int[element_n] elements; this(string type)(ulong number) { pragma(msg, "类型为: " ~ typeof(type).stringof); } } // 阅读全文
posted @ 2022-08-08 23:14
zjh6
阅读(17)
评论(0)
推荐(0)
浙公网安备 33010602011771号