d2

    6热度

    2回答

    我想尽可能快地将单个字节从文件读取到D2应用程序中。应用程序需要每个字节的字节,因此读取较大的数据块不是读取器接口的选项。 为此我在C++,Java,D2中创建了一些简单的实现:https://github.com/gizmomogwai/performance。 正如你所看到的,我尝试了简单的读取,应用程序代码和内存映射文件中的缓冲区。 对于我的用例,内存映射解决方案效果最好,但奇怪的是D2比j

    19热度

    2回答

    有一段时间我对D的运算符重载的方向感到困惑,但现在我意识到这是一个美丽的系统......如果它只适用于核心类型(int,float等)。考虑如下代码: struct Vector { float X, Y; void opOpAssign(string op)(Vector vector) { X.opOpAssign!op(vector.X); // ERROR

    6热度

    1回答

    tl; dr:你如何在D中做perfect forwarding? 链接有一个很好的解释,但是,例如,让我们说我有这样的方法: void foo(T)(in int a, out int b, ref int c, scope int delegate(ref const(T)) d) const nothrow { } 如何创建另一种方法,bar(),它可以代替foo()被调用

    3热度

    3回答

    比方说,我有一个d模板结构: struct Foo(alias pred) {} 我想写一个模板来反省什么预解码是: alias Foo!"a < b" FooLess; static assert(introspectPred!(FooLess) == "a < b"); 有什么简单的方法来做到这一点?如果是这样,introspectPred如何实施?

    5热度

    1回答

    应该如何该C被转换为d: typedef const gchar* (*GModuleCheckInit) (GModule *module); typedef void (*GModuleUnload) (GModule *module); 这是正确的吗? alias const gchar* function(GModule *module) GModuleCheckInit; ali

    7热度

    2回答

    我一直在学习D,特别是对它的泛型编程能力非常兴奋。代表们精彩的,显然他们已经完全取代成员函数指针,所以我被卡住时,我想实现类似如下: template <typename T> void DispatchMethodForAll(std::vector<T*> & container, void (T::* func)(void)) { for(typename std::vecto

    5热度

    1回答

    代码超载 struct test { private real value; this(real value) { this.value = value; } bool opUnary(string op)() if (op == "!") { return !value; } } void

    3热度

    1回答

    测试在d以下 import std.stdio; struct S { int _val; @property ref int val() { return _val; } @property void val(int v) { _val = v; writeln("Setter called!"); } } void main() { aut

    8热度

    5回答

    当我遇到一个有趣的问题时,我正在为D实现一个动态类型库。 现在,我成功地创建了一个名为dynamic()的函数,该函数返回对象的动态版本。 例如: import std.stdio, std.dynamic.core; class Foo { string bar(string a) { return a ~ "OMG"; } int opUnary(string s)(

    5热度

    1回答

    D,作为这一群人中鲜为人知的语言,在图书馆的方式上很少涉猎它。我试图下载一个文件,而我可以看到用DMD 2和phobos来做这件事的方式是使用etc.c.curl,但是......卷曲很难使用。因为我无法在任何地方找到一个好榜样。如何使用etc.c.curl以最简单的方式下载文件?