d

How to install two versions of Qt and tell the application which to use?

这一生的挚爱 提交于 2019-12-10 15:03:02
问题 I am developing an application in Qt, but using D language (with QtD binding). I've noticed that my app crashes with Qt 4.7.x, so I need to use Qt 4.6.2 instead. However in my system Qt 4.7.2 is installed. Unfortunately I neither make QtD work with the latest Qt versions nor (I'm afraid) count on QtD developers... The only thing I need to make my application install in system Qt 4.6.2 libs and use it, but let all the other applications still use Qt 4.7.2. Is it possible? If it is, how to do

Is D powerful enough for these features?

独自空忆成欢 提交于 2019-12-10 14:52:37
问题 For the longest time I wanted to design a programming language that married extensibility with efficiency (and safety, ease-of-use, etc.) I recently rediscovered D and I am wondering if D 2.0 is pretty much the language I wanted to make myself. What I love most is the potential of metaprogramming; in theory, could D's traits system enable the following features at compile time? Run-time reflection: Are the compile-time reflection features sufficient to build a run-time reflection system a la

Where can I read more about D's class access modifiers?

回眸只為那壹抹淺笑 提交于 2019-12-10 14:50:12
问题 I can't seem to find a good reference for the D programming language class access modifiers. I know that public and private are pretty much guaranteed but i'm guessing there are more, i just can't seem to find a good source of information. Can anyone point me to a good reference please? 回答1: You can check the official reference at dlang.org in short: private , is only accessible in the same module (file) package , is only accessible in the same package protected , is module + inherited

error instantiating redBlackTree template

做~自己de王妃 提交于 2019-12-10 14:47:35
问题 I'm having trouble instantiating a RedBlackTree container with chars, but it works with ints: import std.stdio; import std.container; void main() { auto r1 = redBlackTree!(int)(); // works auto r2 = redBlackTree!(char)(); // error instantiating } I'm using DMD32 D Compiler v2.060. Any thoughts? Thanks. 回答1: you need to use a type that is comparable (i.e. can use the < operator or provide your own comparator as the second template parameter char (and wchar) is only useful for use in arrays due

Non Member range functions

拜拜、爱过 提交于 2019-12-10 13:57:07
问题 I have a class that I'm implementing ranges for. I'd like to implement the functions the way the phobos library does, i.e. outside the main class. void popBack(T)(ref T[] a) if (!is(Unqual!T == char) && !is(Unqual!T == wchar)) { assert(a.length); a = a[0 .. $ - 1]; } Here's my version: void popFront(T)(ref PersistentList!(T) a) { a = a.next(); } When I try to compile this code with a forech, I get: Error 1 Error: no property 'popFront' for type 'stmd.PersistentList!(int).PersistentList' main

Why is readf not behaving as expected?

偶尔善良 提交于 2019-12-10 13:56:13
问题 import std.stdio; void main(){ int n; while(readf("%d", &n)){ if(n == 11) break; writeln(n); } } The first iteration works, and it prints n , but after that readf() never returns. The documentation has only a single line explaining readf() : uint readf(A...)(in char[] for­mat, A args); For­mat­ted read one line from stdin. Am I do something wrong? or is there something wrong with readf() ? I just need to read numbers from the standard input. using: DMD 2.054 64-bit 回答1: I believe it's because

Count files in directory with Dlang

旧巷老猫 提交于 2019-12-10 13:39:35
问题 I would like an easy way to count the number of files in a directory using D. As far as I can tell from the D manual, dirEntries returns a range, but this has no length property. I therefore have to iterate through the results with a counter, or gather up the names in a traditional array which I can find the length of... Is there a better way? auto txtFiles = dirEntries(".", "*.txt", SpanMode.shallow); int i=0; foreach (txtFile; txtFiles) i++; writeln(i, " files found.."); 回答1: Ranges

What is the easiest way to use Sqlite in D program on Ubuntu?

試著忘記壹切 提交于 2019-12-10 13:38:56
问题 I suppose using phobos.etc.c.sqlite3 binding. Compiling sqlite3.c using a C compiler to make a .o file and then link it with my program. Which C compiler should I use, and what compiler flags? Is it possible link the sqlite3.o with DMD in one step, without calling linker separately? Or is there some other even easier way? Answer: How to get Sqlite going with D on 64bit Ubuntu install sqlite dev sudo apt-get install libsqlite3-dev compile dmd test.d -L-ldl -L/usr/lib/x86_64-linux-gnu

Pass delegates to external C functions in D

馋奶兔 提交于 2019-12-10 13:38:46
问题 How do I pass a delegate to an external C function taking a function pointer, in D? 回答1: Let me cross post what I said on the newsgroup: How do I pass a delegate to an external C function taking a function pointer? You can't do it directly in general, unless you can modify the C function, then you can hack around it, but a delegate and a regular function pointer are pretty different animals. But perhaps you can magic hack it. Observe: // a C function that needs a plain function extern(C) void

How can D return 0 on success and non-zero on failure if main is void?

ぃ、小莉子 提交于 2019-12-10 13:36:26
问题 In D, the main function is defined: void main(/*perhaps some args but I do not remember*/) { } I know for sure that this function returns zero on success and non-zero on failure and yet it is defined as not returning anything. What is the logic behind it? 回答1: function with void return type does not return any value. There is nothing illogical when you consider call stack looks like this: OS -> D runtime -> main The main function is invoked by D runtime system, which recognized that the main