上一页 1 ··· 62 63 64 65 66 67 68 69 70 ··· 259 下一页
摘要: 参考 #include <源位置> 元<类...T>构 日志{//必须改为源位置,不能用动. 日志(T...t,常 源位置&l=源位置::当前()){ 打印("文件:",l.文件名゛(),l.行(),l.列(),l.函数名()); 打印(t...); } }; 元<类...T>日志(T...)->日 阅读全文
posted @ 2022-06-15 09:50 zjh6 阅读(18) 评论(0) 推荐(0)
摘要: 原文 import std.typecons; import std.meta; Tuple!(int, int, int) iAMfunction() { return tuple(1, 2, 3); } extern(C) int main() {//-betterC int a, b, c; 阅读全文
posted @ 2022-06-14 11:37 zjh6 阅读(17) 评论(0) 推荐(0)
摘要: 原文 import std; struct ParseError { string msg; } alias ParseErrorOr(T) = SumType!(ParseError,T); auto parseErrorOr(T)(T x) { return ParseErrorOr!T(x); 阅读全文
posted @ 2022-06-14 09:44 zjh6 阅读(19) 评论(0) 推荐(0)
摘要: 原文 void main() { int[] arr1 = [4, 9, 7]; int[] arr2 = [5, 2, 1, 10]; int[] arr3 = [6, 8, 3]; sort(chain(arr1, arr2, arr3)); //排序链. writefln("%s\n%s\n% 阅读全文
posted @ 2022-06-13 22:24 zjh6 阅读(21) 评论(0) 推荐(0)
摘要: 原文 void appendLineOffset (int newofs) { auto optr = lineOffsets.ptr; lineOffsets ~= newofs; //检查运行时是否由于数组增长,而分配了新内存块 if (lineOffsets.ptr !is optr) { i 阅读全文
posted @ 2022-06-13 18:32 zjh6 阅读(15) 评论(0) 推荐(0)
摘要: 原文 上个月发布的2.100版本语言已完全删除旧重载符号.但是,使用D出色的元编程功能,可以编写插件模板,来让D1风格重载符号继续工作. 对比D1与D2重载符号 重载符号用来自定义(如+和-)操作符.在D1中,是用普通命名函数,如加法opAdd或乘法opMul.示例,用整来表示内部状态的结构类型: 阅读全文
posted @ 2022-06-13 18:13 zjh6 阅读(27) 评论(0) 推荐(0)
摘要: 如下代码: module a; class Foo { private: int _c; } import b; void handle(Bar child) { child._c += child.c; } // module b; import a; class Bar : Foo { publ 阅读全文
posted @ 2022-06-13 17:34 zjh6 阅读(14) 评论(0) 推荐(0)
摘要: fun! Qjwth(d,c=' ') "这里都是区间外替换,区间内替换用g//,//s/ "d为c符分隔的串,默认为空格, "区间外替换.先是两个区间,然后是2个要替换词语. let[a,b,c,d]=Wmr(a:d,4,"Szw0",a:c) let sl=Sslg(a,b) "这里是区间外.这 阅读全文
posted @ 2022-06-13 15:50 zjh6 阅读(28) 评论(0) 推荐(0)
摘要: 原文 这是我不久前提出的一个gensym实现: enum gensym = q{"_gensym" ~ __traits(identifier, {})["__lambda".length .. $]}; // 同行多次工作. pragma(msg, mixin(gensym)); pragma(m 阅读全文
posted @ 2022-06-13 09:57 zjh6 阅读(16) 评论(0) 推荐(0)
摘要: 原文 void main() { import std.algorithm, std.stdio; [1,2,3,4,5]. map!((x){ writeln("mapping ", x); return x; }). filter!(x=>x>2). front. writeln(); } ma 阅读全文
posted @ 2022-06-13 09:23 zjh6 阅读(20) 评论(0) 推荐(0)
上一页 1 ··· 62 63 64 65 66 67 68 69 70 ··· 259 下一页