摘要:
原文 void foo(void delegate() @system dg) @safe { int *bar; @system void corrupt() { bar = cast(int *)0xdeadbeef;} dg = &corrupt; // 可调用dg吗? }//dip1000都 阅读全文
posted @ 2022-06-22 09:03
zjh6
阅读(15)
评论(0)
推荐(0)
摘要:
原文 因为use包含destroy,所以不能为安全 R use(R, T)(T obj, R delegate(T) fT) { scope (exit) destroy!false(obj); return fT(obj); } 如何确保安全调用destroy? 只要调用它的析构器是@safe的, 阅读全文
posted @ 2022-06-22 09:02
zjh6
阅读(15)
评论(0)
推荐(0)
摘要:
原文 theFirstName[theFirstIndex].theSecondName[theSecondIndex].thirdName[theThirdIndex]=x; //你想改写为如下: alias shortName = theFirstName[theFirstIndex].theS 阅读全文
posted @ 2022-06-22 08:39
zjh6
阅读(17)
评论(0)
推荐(0)
摘要:
事件名意思BufNewFile开始编辑尚不存在文件BufReadPre开始编辑新缓冲区,读文件前BufRead开始编辑新缓冲区,读文件后BufReadPost开始编辑新缓冲区,读文件后BufReadCmd开始编辑新缓冲区前FileReadPre用":read"命令读文件前FileReadPost用" 阅读全文
posted @ 2022-06-21 20:58
zjh6
阅读(114)
评论(0)
推荐(0)
摘要:
原文 结构可以是函子: private @safe struct TranslatableStringPlural { string _str, _strpl; this(string s1, string s2) { // 必须的! _str = s1; _strpl = s2; } string 阅读全文
posted @ 2022-06-21 10:52
zjh6
阅读(17)
评论(0)
推荐(0)
摘要:
原文 struct TranslatedString { private string _str; string get() { return curLang.translate(_str); } alias get this; } template gettext(string str) { ve 阅读全文
posted @ 2022-06-20 22:53
zjh6
阅读(16)
评论(0)
推荐(0)
摘要:
原文 利用D编译时传递格式串给允许用static this()运行时注册格式串的gettext,在version中包装条件,让编译器给你提取串. // File: lang.d version(extractStr) { int[string] allStrings; void main() { i 阅读全文
posted @ 2022-06-20 18:05
zjh6
阅读(18)
评论(0)
推荐(0)
摘要:
原文 我想包含特定模块时更改编译时数组,需要编译时知道数组值. 你可这样: static if (__traits(compiles, { import mymodule; })) { // 包含模块 enum compileTimeArray = ...; } else { // 不包含. enu 阅读全文
posted @ 2022-06-20 09:14
zjh6
阅读(13)
评论(0)
推荐(0)
摘要:
构 A{ 串 a,b; 显 A(串&e){//有它后 a=e.子串(0,1); b=e.子串(0,2); } }; 空 主(){ 串 a{"ab"},b{"ac"}; A e{a,b}; } 这里,想用显 A(串&e)来单独从1个串来构造.但又想保留两个a,b来构造的能力,然而,没用! 编译不了,加 阅读全文
posted @ 2022-06-19 22:17
zjh6
阅读(19)
评论(0)
推荐(0)
摘要:
动&原=量引<串,0,类名>(); 空 动作(向量<串>&一){ 原=一; }//得到的就是引用. 通过这样,就可以避免如下: 空 动作(向量<串>&一){ 原=移动(一); ... 一=移动(原); } 更多信息见此 阅读全文
posted @ 2022-06-19 17:29
zjh6
阅读(10)
评论(0)
推荐(0)
浙公网安备 33010602011771号