10 2022 档案

摘要:原文 我正在写chip8仿真器.正在加载rom到内存中.根据文档,每个指令是2个字节,最大内存地址是4K.所以按正短数组定义内存. struct Chip8 { ushort[4096] memory; ... 这样,加载它: void read(string rom) { import std.f 阅读全文
posted @ 2022-10-31 20:01 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:import core.stdc.stdio : printf; struct C { static void f() { printf("C\n"); } } struct D { static void g() { printf("D\n"); } } struct B(C,D){ void s 阅读全文
posted @ 2022-10-30 12:00 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:原文 Zig没有gc.D的gc是可选的. 我承认该点.它永远不会像GO的GC那样快.原因是技术上的.GO是一种只支持GC的语言,即它是为GC优化的.所有GO分配都是在GC堆上分配的,尽管它确实做了逃逸分析,以确定哪些可分配到栈上.(Java也有.) 对繁重的GC分配,合理的折衷方案是在每次用指针写入 阅读全文
posted @ 2022-10-29 13:13 zjh6 阅读(26) 评论(0) 推荐(0) 编辑
摘要:原文 struct C { int[] data; } struct S { private int[][string] aa; inout(C) func(string key) inout { return inout(C)(aa[key]); } inout(C) gunk(string ke 阅读全文
posted @ 2022-10-29 12:36 zjh6 阅读(13) 评论(0) 推荐(0) 编辑
摘要:这里为特化 上面链接为针对各种浏览器应用的特化. 还可定制他们的共性,即各种浏览器应用的共性特点. 允许浏览(){ return (WinActive("ahk_class Chrome_WidgetWin_1")) } #If 允许浏览() ;所有chrome浏览器. /::click #If 通 阅读全文
posted @ 2022-10-29 10:03 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:复制网址 #IfWinActive ahk_exe 360chrome.exe ^LAlt::谷哥翻译() $F6::复制网址1() #IfWinActive ;要求屏幕最大, #IfWinActive ahk_exe msedge.exe ^LAlt::腾讯翻译() $F6::复制网址2() #I 阅读全文
posted @ 2022-10-29 09:50 zjh6 阅读(28) 评论(0) 推荐(0) 编辑
摘要:复制网址1(){ send {F11} sleep 100 send {F6}^c{esc} sleep 200 send {F11} sleep 100 click 787,255 ;用f11,复制网址,再休息下 ;这里在顶上某个地方再点了下,避免不能移动 } 复制网址2(){ send {F6} 阅读全文
posted @ 2022-10-29 09:48 zjh6 阅读(59) 评论(0) 推荐(0) 编辑
摘要:整 f(整 i){ 中 2*i; } 元<动 e>整 h(整 j){ 中 e(j); } 空 主(){ 整 i=h<f>(3);//直接把函数作模板参数! 打印(i); } 也可专门针对该类型,来特化,这里E就算概念(约束)了. 用 E=整(整); 然后,改动为E,这样,就可以特化了. 这样,以函数 阅读全文
posted @ 2022-10-28 20:22 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:原文 如何防止编译器删除想要测量代码? 为了防止优化器完全忽略函数,需要处理返回值,一般,即要把返回值合并到某个累加变量中,如,如果它是int函数,就有个你要加的运行的int累加器: int funcToBeMeasured(...) pure { ... } int accum; auto res 阅读全文
posted @ 2022-10-28 19:14 zjh6 阅读(14) 评论(0) 推荐(0) 编辑
摘要:原文 问题是何时分配[1,2,3]到栈上,何时分配到GC堆上? 要点: 1.在C中,它是在栈上分配的.D分配其到堆,这里有点令人惊讶,尽管D在C之前就有这样的字面 2.在堆上分配表明它在@nogc代码中不可用. 3.编写表达式时,放在栈上的唯一方法是给它赋值不方便又低效的域变量. 4.它违背了简单代 阅读全文
posted @ 2022-10-27 10:02 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:原文 'fn'嵌套函数不能推导得到'return'. int* gPtr; void main() @safe { scope int* sPtr; int* fn() { return sPtr; } gPtr = fn(); } 最好方法可能是允许非静态嵌套函数具有'return'和'scope 阅读全文
posted @ 2022-10-27 09:34 zjh6 阅读(8) 评论(0) 推荐(0) 编辑
摘要:原文 @safe: void main() { import std.stdio : writeln; writeln(ubyte(4).toHexDigit); } ubyte toHexDigit(ubyte decimal) pure nothrow @nogc { if (decimal < 阅读全文
posted @ 2022-10-27 09:20 zjh6 阅读(15) 评论(0) 推荐(0) 编辑
摘要:原文 可定义enum INLINE=true, 并使用pragma(inline,INLINE),而不是pragma(inline,true).这样,当不希望编译器内联时,可切换INLINE为false. 阅读全文
posted @ 2022-10-26 14:43 zjh6 阅读(20) 评论(0) 推荐(0) 编辑
摘要:原文 改变结构位置会怎样?所以在main()时,X结构一定在栈中,而下面的一定在堆中,是吧? import std; //void main() { struct X { struct Y { int i = 10; alias i this; } Y[] y = [Y.init];//.1 str 阅读全文
posted @ 2022-10-26 11:22 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:原文 struct A { int[] i; } struct B { A[] a = [A.init]; } A和B如上,代码: auto b1 = B.init; b1.a[0].i ~= 1; b1.a ~= A.init; b1.a[0].i ~= 11; b1.a[1].i ~= 12; 阅读全文
posted @ 2022-10-26 10:21 zjh6 阅读(11) 评论(0) 推荐(0) 编辑
摘要:原文 auto screen = executeShell(cmdLine); auto s;//这样声明? //无法推导`"s"`的类型. //从`getPath`的返回类型来看,可能是`string[]`. //应该这样 string[] s; ... { s = screen.output.f 阅读全文
posted @ 2022-10-26 09:17 zjh6 阅读(8) 评论(0) 推荐(0) 编辑
摘要:#include <常用> 元<类 M>构 A{ 空 f(){M::g();} }; 构 C{ 单 串 首,尾; 静 空 切换(串&a,串&b){首=a;尾=b;} 静 空 g(){ 打印(首,尾); } }; 空 ff(){ 串 a{"ab"},b{"cde"}; C c;c.切换(a,b); A 阅读全文
posted @ 2022-10-25 17:36 zjh6 阅读(13) 评论(0) 推荐(0) 编辑
摘要:原文 void foo() @trusted { static struct T { Exception ex; ubyte[] buf; } scope buffer = new ubyte[100]; T t; t.ex = new Exception("hello"); t.buf = buf 阅读全文
posted @ 2022-10-25 15:18 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:function ff(){ var a=q('.jiu-content.card-bleed.mb-3.shadow-light.p-3.p-md-5.p-sm-3.bg-white.rounded').parentNode; jl0(a,'col-md-8'); } //setTimeout(" 阅读全文
posted @ 2022-10-25 13:55 zjh6 阅读(9) 评论(0) 推荐(0) 编辑
摘要:策略思想不仅可应用至类,还应可应用至函数,甚至可以是变量! C++没有函数模板作为插件的功能,非常不方便! 但是,D中是有的!这样策略类思想不仅可应用至类,还可应用至函数! 导入 标.标口; 整 h(整 I,T)(T b){中 I*b.长度;} 空 g(用 h,整 I,T...)(T t){ 每一( 阅读全文
posted @ 2022-10-25 11:19 zjh6 阅读(120) 评论(0) 推荐(0) 编辑
摘要:原文 如何实现迭代构/类?这样: foreach (k, v; T.init) { ... } T.byKeyValue没用. 参考在此 你应该用opApply.示例: struct A { static int[string] impl; static this() { impl = [ "a": 阅读全文
posted @ 2022-10-25 10:52 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:import std.stdio; struct A { static int[string] impl; static this() { impl = [ "a": 1, "b": 2, ]; } int opApply(scope int delegate(string a, int b) dg 阅读全文
posted @ 2022-10-25 10:45 zjh6 阅读(11) 评论(0) 推荐(0) 编辑
摘要:原文 在四个条件下会出错: import std.stdio; import std.datetime; alias T = real; // 必须为'real' enum testCount = 7; // 必须> 6 T foo() { // 必须返回值 return 42; } void ma 阅读全文
posted @ 2022-10-25 09:35 zjh6 阅读(9) 评论(0) 推荐(0) 编辑
摘要:原文 重载路径: struct Path { string value; Path opBinary(string op)(in string path) if(op == "/") { import std.path : buildPath; return Path(buildPath(value 阅读全文
posted @ 2022-10-25 09:26 zjh6 阅读(8) 评论(0) 推荐(0) 编辑
摘要:基类: 元<类 M,类 N=默认并> 构 A{ 空 动作(){ ... N::并(参数); ... } }; 现在,添加个新策略类,也可有默认策略,在N=默认并中.然后,我们目的是实现N::并函数. 这里并函数,为静态函数. 构 C{ 单 串 首,尾; 静 空 切换(串&a,串&b){首=a;尾=b 阅读全文
posted @ 2022-10-24 23:11 zjh6 阅读(8) 评论(0) 推荐(0) 编辑
摘要:元<别名 F,类...T>空 gg(F&f,T&...t){ 断定(f(t)&&...); } C++没有别名,不能实现上面的功能,因为推导不出来!可是,C++会服输吗? 不会!因为C++有万能的宏!一宏在手,天下我有! #define 连与(F) \ 元<类...T>极 多##F(T&&...t) 阅读全文
posted @ 2022-10-24 22:38 zjh6 阅读(11) 评论(0) 推荐(0) 编辑
摘要:导入 标.标口; //整 h(整 I)(串 b){中 I*b.长度;} 整 h(T)(T b){中 b.长度;} 空 g(用 h,T...)(T t){ 每一(p;t)写行(h(p)); } 空 主(){ 串 a="ab",b="cd"; g!h(a,b); } 这里C++版本,是编译不过的.C++ 阅读全文
posted @ 2022-10-24 22:04 zjh6 阅读(8) 评论(0) 推荐(0) 编辑
摘要:就问你怕不怕! 我明明启动的时候就禁止自动更新服务了,可是又启动了! 先,1,组策略禁止自动更新 2,禁止自动安装驱动 这里又有问题,自从点了power tool这个软件,给你更新驱动,解决不完的问题! 这个组策略现在也变成英文的了.真是恶心! 你用别人的软件,永远不知道他的下一个坑在哪里! 这个教 阅读全文
posted @ 2022-10-24 16:52 zjh6 阅读(56) 评论(0) 推荐(0) 编辑
摘要:#IfWinActive ahk_exe 360chrome.exe ^LAlt::谷哥翻译() #IfWinActive ;要求屏幕最大, #IfWinActive ahk_exe msedge.exe ^LAlt::腾讯翻译() #IfWinActive 根据不同的应用名,对同一按键实现相同功能 阅读全文
posted @ 2022-10-24 15:27 zjh6 阅读(13) 评论(0) 推荐(0) 编辑
摘要:html,body,html h1,html p,html div,span,li a,h2,h3,h4,h5,strong,section{ font-family:simsun!important; //这是新宋,因为楷体对应的英文不好看. } font,.post-text.markdown{ 阅读全文
posted @ 2022-10-24 14:57 zjh6 阅读(9) 评论(0) 推荐(0) 编辑
摘要:d复制与原位排序 enum Direction { asc, desc } enum InPlace : bool { no, yes } ref Arr sort(ref Arr arr, Direction dir, InPlace inPlace = InPlace.no) { if (inP 阅读全文
posted @ 2022-10-24 14:29 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:int* foo(return scope int* x)@safe{ auto y=x; int t; auto z=&t; return y; // 可,但不返回z } 它并不跟踪生命期,它只是从x复制属性到y.因为它是用栈变量地址初化的,所以z取scope属性. @live的目的是为了防止: 阅读全文
posted @ 2022-10-24 13:27 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:优点:速度快. 缺点:1,快捷键不友好! 2,对中文不友好! 3,对字体不友好.我居然设置不了字体!一个标准字体就把所有的东西控制完了.简直是太恶心了! 4,配置不友好,已经非常难配置了!连基本的快捷键配置都没有! 什么高版本,垃圾罢了! 阅读全文
posted @ 2022-10-24 11:39 zjh6 阅读(26) 评论(0) 推荐(0) 编辑
摘要:我已经见识了很多软件,这些软件安装的时候,你无论如何,你只能用鼠标,你连TAB按键都用不了.这些厂商是返祖了吗? 你让我不能安装,我只好不用你的产品了.很简单道理. 阅读全文
posted @ 2022-10-24 09:39 zjh6 阅读(9) 评论(0) 推荐(0) 编辑
摘要:一直按键,用了power tool给你更新驱动,结果就是一会又一直按键44444444444444444444. 就问你受不受得了. 服务找遍了,该删的都删了,没用.总会一直按键. 现在在设备管理器里面,删掉键盘驱动. 设备管理器--键盘 hid.这里有3个hid,正常的是usb接口(外部)驱动. 阅读全文
posted @ 2022-10-24 09:22 zjh6 阅读(165) 评论(0) 推荐(0) 编辑
摘要:二批(名向量); 这个宏放在常用的前面可以,但是放在本文件,就是编译不过,说有问题. 这是由于名向量可能有多个该函数名的函数.冲突了.在函数名之后,还有个名向量,编译器识别不了. 另一个问题 C++不能简单别名: 元<类...T>用 f=g<T...>; //g为函数模板 不能这样,编译不过.C++ 阅读全文
posted @ 2022-10-23 21:39 zjh6 阅读(9) 评论(0) 推荐(0) 编辑
摘要:导入 标.标口; 空 f(整 I)(整 i){ 整 e=I*i;写行(e); } 别名 g=f!30; 空 主(){ g(2); } // 元<整 I>空 f(整 i){ 整 e=I*i; 打印(e); } 用 g=f<30>;//不行,编译不了. 空 主(){ g(2); } 阅读全文
posted @ 2022-10-23 20:53 zjh6 阅读(20) 评论(0) 推荐(0) 编辑
摘要:原文 通过传递InputRange而不是const(char)给toCStringThen来提供无分配0终止串. //version=AllowMalloc;//.1 auto toCStringThen(alias dg, Range)(Range src) /*nothrow*/ if (isI 阅读全文
posted @ 2022-10-23 15:21 zjh6 阅读(14) 评论(0) 推荐(0) 编辑
摘要:原文 用dub立马降速几秒.因为要花费大量时间积极优化,LDC一般比DMD要慢一些.对开发构建,请考虑使用DMD. :此跟踪时间花了9秒.DMD构建项目需要7秒钟.Adam在2.5秒内构建了他的整个arsd,而PC速度更快,arsd比项目大得多,这没有意义. 速度慢原因: 1,使用许多嵌套模板. 2 阅读全文
posted @ 2022-10-23 14:47 zjh6 阅读(18) 评论(0) 推荐(0) 编辑
摘要:原文 import parserino; void main() { //Parserino修复你的html5 Document doc = "<html>超文"; assert(doc.toString() == "<html><head></head><body>超文本</body></html 阅读全文
posted @ 2022-10-23 14:18 zjh6 阅读(11) 评论(0) 推荐(0) 编辑
摘要:参考 按alt+tab,一个edge占用大量位置. 按照参考,把多个改成1个.即系统-多任务-alt tab. 微软的控制面板,越做越回去,一点都不喜欢. 不能用快捷键,不能输入中文,只能用鼠标滚轮.够恶心吧! 阅读全文
posted @ 2022-10-23 10:14 zjh6 阅读(22) 评论(0) 推荐(0) 编辑
摘要:原文 import std.algorithm: splitter, filter; import std.uni: isWhite; // 或用std.ascii import std.array: array; import std.stdio: writeln; string exampleT 阅读全文
posted @ 2022-10-23 10:01 zjh6 阅读(8) 评论(0) 推荐(0) 编辑
摘要:原文 找关联数组并迭代 我正在固定的串列表中搞DFS之类.如生成串排列,但是搜索条件很复杂,要尽量"提前退出".即,只要看到第一个或第二个单词,就可修剪树枝. import std; void main() { auto m = iota(20).map!(i => tuple(i, format! 阅读全文
posted @ 2022-10-23 09:56 zjh6 阅读(8) 评论(0) 推荐(0) 编辑
摘要:现在的浏览器基本上都是谷哥浏览器为核,所以配置他们大同小异. 配置,主要是插件: 1,Vimium C 用于vim式浏览,基本上是必备,选项是: map n previousTab map m nextTab map b Vomnibar.activateBookmarksInNewTab map 阅读全文
posted @ 2022-10-23 08:57 zjh6 阅读(61) 评论(0) 推荐(0) 编辑
摘要:1,360极速.目前最常用的就是32位的360极速. 64位的极速,因为是谷哥的高版本,所以还有点不爽.比如不能中文直接输出,必须要用英文才能输出.360极速当下是最好的. 2,但是,由于谷哥翻译翻译不了了,老是断网.我又试用了其它几个浏览器. 3,QQ浏览器,宽度有问题,100%的时候,宽度在外面 阅读全文
posted @ 2022-10-22 23:32 zjh6 阅读(88) 评论(0) 推荐(0) 编辑
摘要:#include <常用> 元<类 T>构 A{ 空 f(){ T::g(); } }; 构 B{ 静 空 g(){ 打印("啊B"); } }; 元<符 C,整 I>构 E{ 静 空 g(){ 静 串 e=重复(C,I); 打印(e); } }; 空 主(){ A<B> e;e.f(); A<E< 阅读全文
posted @ 2022-10-22 16:28 zjh6 阅读(9) 评论(0) 推荐(0) 编辑
摘要:一直按键又来了.可能是用了powertool更新了几个驱动啥的,真是,又来了.就问你怕不怕,一直按键4444444444444444444,简直是恐怖. 以后一定要记得,别人的软件少用,太坑了.一不注意,就掉坑里面了. 启动的bat里面加上这句: sc config i8042prt start=d 阅读全文
posted @ 2022-10-22 15:03 zjh6 阅读(345) 评论(0) 推荐(0) 编辑
摘要:在实现一个功能时,通过定制不同策略来提供不同功能.本来是F中的f,但我们不用λ,λ太难看. 我们把λ放进构里面包装,然后取个名字,以后就可以直接用了,所以这个构名就是个策略名字. 如下,1是概念,2是基本功能: 元<类 T>概念 可分块=要求(T&a,串&b){a.分开(b);}; 元<可分块 T> 阅读全文
posted @ 2022-10-22 11:35 zjh6 阅读(19) 评论(0) 推荐(0) 编辑
摘要:上文 上面方法不管用.用powertool定位到这里 Computer\HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced 再次修改注册表为: Windows Registry Editor Ve 阅读全文
posted @ 2022-10-21 16:16 zjh6 阅读(13) 评论(0) 推荐(0) 编辑
摘要:不知道怎么回事,开机就给你自动隐藏扩展名.总是恶心.试试注册表: Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\ 阅读全文
posted @ 2022-10-21 10:21 zjh6 阅读(8) 评论(0) 推荐(0) 编辑
摘要:import std; struct Matrix(size_t X, size_t Y = X) { enum x_length = X; // 编译时可用 enum y_length = Y; double[X * Y] data; // 重载操作符 Matrix opBinary(string 阅读全文
posted @ 2022-10-20 09:13 zjh6 阅读(15) 评论(0) 推荐(0) 编辑
摘要:来吧,让我们扯淡一下垃圾一般的win11吧. 我现在打开目录,创建文件,都是用vim搞的,windows自带的,都是垃圾,打开就崩溃,连最基础的功能都搞不好! 垃圾一般的控制面板!连个快捷键都用不了! 后台不知道什么的程序,改我输入法.我每次都要手动改回来! 最近,每次开机后,都给你隐藏扩展名,我每 阅读全文
posted @ 2022-10-19 09:15 zjh6 阅读(74) 评论(0) 推荐(0) 编辑
摘要:运行时更改 添加了avx512f检测到core.cpuid 已添加core.cpuid.avx512f特征标志,来允许在具有512位向量支持的CPU上运行时检测. 删--DRT-oncycle=deprecate 参考 帮助迁移,模块构造器的旧的易错循环检查器.现在与--DRT-oncycle=ab 阅读全文
posted @ 2022-10-18 15:40 zjh6 阅读(15) 评论(0) 推荐(0) 编辑
摘要:原文 都是编译器更改.剩下的略了. 添加位域到D 1链接,2链接 struct B { int x:3, y:2; } static assert(B.sizeof == 4); int vaporator(B b) { b.x = 4; b.y = 2; return b.x + b.y; // 阅读全文
posted @ 2022-10-18 11:54 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:D的输出区间 原文 import std.stdio; import std.range; void main() { int[] arr = [1, 2, 3, 4, 5]; auto s = arr; writeln(s); // [1, 2, 3, 4, 5] s.put(100); // 无 阅读全文
posted @ 2022-10-18 10:12 zjh6 阅读(15) 评论(0) 推荐(0) 编辑
摘要:自动柯里化 f(a,b,c)按f(a)(b)(c)调用. template autocurry(alias what) { import std.traits; static if(Parameters!what.length) auto autocurry(Parameters!what[0] a 阅读全文
posted @ 2022-10-17 19:36 zjh6 阅读(21) 评论(0) 推荐(0) 编辑
摘要:反射示例 import std.stdio; import std.conv; import std.traits; class MyClass { void myMethod() {} int anotherMethod(int a) { return a; } // 运行时桥函数,技巧是编译时反 阅读全文
posted @ 2022-10-17 17:16 zjh6 阅读(9) 评论(0) 推荐(0) 编辑
摘要:原文 public abstract class GlobalTradeItemNumber { // 可仅return _digits.length public abstract @property size_t length(); 代码: public /* //该行是错的. //GTIN14 阅读全文
posted @ 2022-10-17 14:26 zjh6 阅读(11) 评论(0) 推荐(0) 编辑
摘要:枚举当索引 enum Foo { one, two } struct struct_t {} struct array { static private struct_t[Foo.max + 1] content; static struct_t opIndex(Foo idx) { return 阅读全文
posted @ 2022-10-17 10:04 zjh6 阅读(7) 评论(0) 推荐(0) 编辑
摘要:原文 链接 module example; import std.stdio; import emu6502; void main() { ubyte[0x10000] memory; ubyte[] code = [ 0xA2, 0x00, // lda #0 // 循环: 0xBD, 0x0E, 阅读全文
posted @ 2022-10-17 09:18 zjh6 阅读(17) 评论(0) 推荐(0) 编辑
摘要:只运行一次 int sumN(int n)() pure { int result = 0; for (int i = 0; i<=n; i++) result += i; return result; } void main() { enum sumMany = sumN!2000000; enu 阅读全文
posted @ 2022-10-16 21:53 zjh6 阅读(67) 评论(0) 推荐(0) 编辑
摘要:原文 题目: template AFields() {int a;} struct A { mixin AFields; } template BFields() {int b;} struct B { mixin BFields; } struct AB { mixin AFields; mixi 阅读全文
posted @ 2022-10-16 17:51 zjh6 阅读(30) 评论(0) 推荐(0) 编辑
摘要:import std.stdio; struct Commands { static://置为静 void func001() {writef("1啊");} //假定空,且无参 void func002() {writef("2哈");} } void main(string[] args) { 阅读全文
posted @ 2022-10-16 17:08 zjh6 阅读(8) 评论(0) 推荐(0) 编辑
摘要:原文 如何"提取"并使用闭包中的函数指针? struct S { void function () fp; void foo () { fp = (&bar).funcptr; } void bar () { fp = (&foo).funcptr; } auto fun () // 帮助函数 { 阅读全文
posted @ 2022-10-16 10:17 zjh6 阅读(11) 评论(0) 推荐(0) 编辑
摘要:原文 import std.stdio; class Math { static string noArgs(string[] s) { writeln(s); return ""; } static string withOneArg(string[] s) { writeln(s); retur 阅读全文
posted @ 2022-10-15 22:15 zjh6 阅读(28) 评论(0) 推荐(0) 编辑
摘要:原文 import std.stdio; import std.typecons; alias ScopedBar = typeof(scoped!Bar()); //域bar. class Bar { this() { writeln("Bar"); } ~this() { writeln("~B 阅读全文
posted @ 2022-10-15 21:20 zjh6 阅读(7) 评论(0) 推荐(0) 编辑
摘要:原文 不要在你的opBinary上返回ref.你不能通过ref返回新事物,只能返回成员变量.所以取下ref并替换其为auto.然后编译. auto opBinary(string op, Rhs : meter!(otherValueT), otherValueT) (in Rhs rhs) 代码: 阅读全文
posted @ 2022-10-15 21:09 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:工作时,创建类(使用自己包装器,或可用Object.factory并用动态调度函数把它转换为某个通用接口),然后使用动态函数.就像: // 注意: 工厂要`模块+类`全名 auto foo = cast(MyDynamic) Object.factory("mymodule.Foo"); asser 阅读全文
posted @ 2022-10-15 20:10 zjh6 阅读(13) 评论(0) 推荐(0) 编辑
摘要:原文 它必须是用户定义的.D中的内置数组要么是静态的,需要在编译时知道,要么是切片成动态数组,可以调整大小. 内置选项: int length = 100; int[] int_array = new int[length]; //== int[] int_array; int_array.leng 阅读全文
posted @ 2022-10-15 18:15 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:原文 import std.typetuple; alias list = TypeTuple!(AA, AB, AC); 但是,不能在运行时像数组一样索引它;尝试newlist[n]将是编译时错误.相反,创建辅助函数来循环它并返回实例,如下所示: foreach(index, type; list 阅读全文
posted @ 2022-10-15 17:55 zjh6 阅读(20) 评论(0) 推荐(0) 编辑
摘要:原文 我想到了两种可能性.一个是使用UFCS,定义类型作为第一个参数的其他模块中命名函数(它不适合操作符重载),然后可用点语法调用: module myvector; struct vector { float x; float y; } // module myvectormath; import 阅读全文
posted @ 2022-10-15 17:09 zjh6 阅读(11) 评论(0) 推荐(0) 编辑
摘要:原文 代码在此 输出: Processing: module main Processing: module object Processing: module c Processing: module attr test2() has sillyWalk main() has sillyWalk 阅读全文
posted @ 2022-10-15 15:04 zjh6 阅读(15) 评论(0) 推荐(0) 编辑
摘要:原文 ldc支持gdc风格汇编 avrd d的avr 有两个选项可链接ldc发出的编译目标文件:用avr-gcc的链接器,或用llvm的内部链接器.-gcc=avr-gcc参数告诉在哪查找avr-gcc工具,或可用使用llvm的内置链接器的--link-internally.两者都会起作用. 使用- 阅读全文
posted @ 2022-10-15 14:32 zjh6 阅读(41) 评论(0) 推荐(0) 编辑
摘要:struct Operator(alias fn, string operator = "/") { static auto opBinaryRight(string op : operator, T...)(T value1) { struct Result { auto opBinary(str 阅读全文
posted @ 2022-10-15 08:53 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:原文 下载地址 在ImportC之前,翻译glfw-d和libsoundio-d来帮助翻译的工具. 1库,2库. 用树解析器帮助解析包括预处理器指令的.c或.h文件,然后在需要时,用大致等效的D模式替换C语法模式. 示例: #include <stdio.h> #define TAU 6.28318 阅读全文
posted @ 2022-10-14 09:06 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:struct X { Y y; ref Y getY() return { return y; } } 告诉编译器getY()返回基于隐式"this"引用的引用.它现在可用(DIP25是它的提议). 现在正在实现增加了支持指针值的DIP1000(DIP25只处理引用).实际效果: alias Y = 阅读全文
posted @ 2022-10-13 19:53 zjh6 阅读(7) 评论(0) 推荐(0) 编辑
摘要:DonClugston最先发现的.假设我有带成员函数的结构: struct S { int s; pure void set(int i) { s = i; } 现在,即使在强纯函数中,我也可以使用弱纯函数,即使它通过参数改变状态: pure int foo(int i) { S s; s.set( 阅读全文
posted @ 2022-10-11 22:39 zjh6 阅读(13) 评论(0) 推荐(0) 编辑
摘要:dmdD编译器有内置覆盖分析器: |bool foo(bool i, bool j) { 2| return i || 1| j; |} | |void main() { 1| foo(true, false); 1| foo(false, false); |} 它计数每条语句,并将逻辑表达式操作计 阅读全文
posted @ 2022-10-11 22:08 zjh6 阅读(13) 评论(0) 推荐(0) 编辑
摘要:int *_memset32(int *p, int value, size_t count) { asm { mov EDI,p ; mov EAX,value ; mov ECX,count ; mov EDX,EDI ; rep ; stosd ; mov EAX,EDX ; } } 编译器为 阅读全文
posted @ 2022-10-11 16:46 zjh6 阅读(11) 评论(0) 推荐(0) 编辑
摘要:原文 上一篇文章显示了如何用新的DIP1000规则让切片和指针内存安全的引用栈.但是D也可其他方式引用栈. 面向对象实例 前面说过,如果了解DIP1000如何同指针工作,那么就会了解它如何同类工作.示例: @safe Object ifNull(return 域 Object a, return 域 阅读全文
posted @ 2022-10-10 20:31 zjh6 阅读(25) 评论(0) 推荐(0) 编辑
摘要:原文 ref int f(ref return scope int* p) @safe { return *p; } 按引用+中域编译,保护p值,而非p地址,成功编译,因为p就是返回值. 而: ref int f(ref scope return int* p) @safe { return *p; 阅读全文
posted @ 2022-10-09 15:10 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:dchar dstrValue = '5'; dchar ch = '0' + intValue; dchar ch = cast(dchar) intValue; 阅读全文
posted @ 2022-10-06 10:30 zjh6 阅读(14) 评论(0) 推荐(0) 编辑
摘要:谷哥不能翻译了,怎么办? 114.250.66.34 translate.googleapis.com 203.208.40.66 translate.google.com 203.208.40.66 translate.googleapis.com 上面加入C:\Windows\System32\ 阅读全文
posted @ 2022-10-05 20:17 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:原文 与GC按需分配和释放串速度相比,人类阅读速度非常慢. FormatSpec只在toString实现中用做有用事情时,才用它.要提供默认说明符的方便重载. struct A { string message; int enthusiasm; void toString(DG)(scope DG 阅读全文
posted @ 2022-10-05 16:19 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:原文 我希望可存储类实例到关联数组中,供以后使用,最小示例: interface PathConverter { T toD(T)(string value); } class NumberConverter(T) : PathConverter { T toD(T)(string value) { 阅读全文
posted @ 2022-10-05 15:47 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:原文 //extern (C) public int registerDDelegate(alias Func,...) class C { string s; void foo() { import std.stdio : writeln; writeln("看", s, "用D!"); } } 阅读全文
posted @ 2022-10-05 15:34 zjh6 阅读(8) 评论(0) 推荐(0) 编辑
摘要:原文 void main() { import std.range; import std.stdio: write, writeln, writef, writefln; int[] arr1 = [ 1, 2, 3, 4 ]; int t = 0; writeln(arr1); for (int 阅读全文
posted @ 2022-10-05 15:12 zjh6 阅读(15) 评论(0) 推荐(0) 编辑
摘要:原文 传递λ给纤程构造器. void fiberFunc(int i) { writeln(i); } void main() { auto fiber = new Fiber(() => fiberFunc(5)); fiber.call(); } 还可创建与对象一起存储的Fiber子类. 阅读全文
posted @ 2022-10-05 13:43 zjh6 阅读(9) 评论(0) 推荐(0) 编辑
摘要:原文 struct pair { float x; float y; } pair[10] values; import std.conv; auto valuesInCStyle = to!(const float*)(values); 现在不行,可这样: cast(float*) values. 阅读全文
posted @ 2022-10-05 13:38 zjh6 阅读(9) 评论(0) 推荐(0) 编辑
摘要:原文 是否可在不丢失容量下从区间中删除元素? void main() { import std.algorithm.mutation : remove, SwapStrategy; import std.stdio : writeln; int[] arr = [1, 2, 3, 2, 4, 2, 阅读全文
posted @ 2022-10-05 13:31 zjh6 阅读(35) 评论(0) 推荐(0) 编辑
摘要:原文 import std.stdio: writeln; struct MyObject { int id; this(int id) @nogc { this.id = id; } ~this() { writeln("Object destructor ..."); } } void main 阅读全文
posted @ 2022-10-05 13:15 zjh6 阅读(10) 评论(0) 推荐(0) 编辑
摘要:为了保护D免受抄袭指控,我不会查看其他编译器源代码.这不仅仅是我的偏执狂,曾多次(错误地)指控我,包括接受律师的采访.“我从没看过他们的代码"是一种非常有效防御方式.在一屋子律师里面,他们很惊讶我这么说,让我确认一下,然后宣布"到此为止”,然后走了出去.再也没有收到他们的消息. 阅读全文
posted @ 2022-10-05 12:53 zjh6 阅读(8) 评论(0) 推荐(0) 编辑
摘要:#include <常用> 元<整 N>构 AA{ 整 I;符 p[N]{}; 常式 AA(常 符(&pp)[N]){ 区间们::复制(pp, p);I=N; }; }; 元<AA a>常式 动 符号""d(){ 中 a.p; } 元<AA a>常式 动 符号""z(){ 中 a.I; }//这种思 阅读全文
posted @ 2022-10-03 21:51 zjh6 阅读(12) 评论(0) 推荐(0) 编辑
摘要:元<常符*c>构 字典{ }; 上面这样,输入文件名,在同时用两个字典的子类时,会出现问题,报错1179链接错误,说字典已有comdat. 改为: 元<常符*c,类 T=空>构 字典{ }; 不仅要输入字典名,还要加上T. 阅读全文
posted @ 2022-10-03 18:49 zjh6 阅读(7) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示