摘要:
import core.stdc.stdio : printf; extern (C++) interface A { void sayHello(); } extern (C++) class B : A { void sayHello() { printf("hello\n"); } } ext 阅读全文
posted @ 2022-01-21 21:35
zjh6
阅读(14)
评论(0)
推荐(0)
摘要:
如何去样板: auto someRandomName = f(...); //f返回包含两部分的元组 auto firstPart = someRandomName[0]; auto secondPart = someRandomName[1]; 我会这样: /// 按参数传递元组的成员给函数 te 阅读全文
posted @ 2022-01-21 13:26
zjh6
阅读(13)
评论(0)
推荐(0)
摘要:
如何传递和处理两组可变参数? void fun(Args...)(Args args) if (args.length % 2 == 0) { alias firstSet = args[0 .. $/2]; alias secondSet = args[$/2 .. $]; // 其余函数体... 阅读全文
posted @ 2022-01-21 11:30
zjh6
阅读(16)
评论(0)
推荐(0)
摘要:
别名允许为程序中某处已存在实体创建新名字. "实体"可为:类型,变量,函数,模块,模板,但它必须是独立于别名而存在的.即,不能用alias来给还没有名字的命名. 但是等等,你可能会问,你又怎么能给λ起别名呢?这是匿名函数;根据定义,它没有名字! alias increment = (int x) = 阅读全文
posted @ 2022-01-21 11:01
zjh6
阅读(48)
评论(0)
推荐(0)
摘要:
添加-version=library到库的编译器标志中,并将添加-version=executable到可执行文件的编译器标志中.然后,代码中,可检查"版本(库)"和"版本(可执行)". 阅读全文
posted @ 2022-01-20 19:24
zjh6
阅读(14)
评论(0)
推荐(0)
摘要:
mixin template parameterAliases(names...) { static if (is(typeof(__traits(parent, {})) params == __parameters)) static foreach (i, name; names) mixin( 阅读全文
posted @ 2022-01-20 18:51
zjh6
阅读(48)
评论(0)
推荐(0)
摘要:
原文 module test; import std.stdio : writeln; import std.range : iota, isForwardRange, hasSlicing, hasLength, isInfinite; import std.array : array, Appe 阅读全文
posted @ 2022-01-20 17:30
zjh6
阅读(14)
评论(0)
推荐(0)
摘要:
import std.traits; import std.stdio; enum Runnable; struct SubSystem { void run() { writeln("SubSystem ran"); } } struct Manager { @Runnable SubSystem 阅读全文
posted @ 2022-01-20 17:27
zjh6
阅读(32)
评论(0)
推荐(0)
摘要:
D中,目前有几种不同的方式可以引用类型 1)按名称. int x;//`按名称引用`int 2)按别名. alias T = int; T x; //按别名T引用int 3)按模板参数. template foo(T) { T x; // 按`T`参数引用类型 } 4)按typeof表达式. typ 阅读全文
posted @ 2022-01-20 10:11
zjh6
阅读(48)
评论(0)
推荐(0)
摘要:
import std.stdio; import std.conv; void main() { writefln("0b%b", to!int("111000", 2)); } 阅读全文
posted @ 2022-01-20 09:28
zjh6
阅读(20)
评论(0)
推荐(0)
浙公网安备 33010602011771号