Re: Error when exiting program

2011-02-18 Thread Jesse Phillips
Joel Christensen Wrote: > I'm using some one else's bindings to a C library. > > The problem seems to be limited to D2 programs. > > Error as follows: > An exception was thrown while finalizing an instance of class jec2.bmp.Bmp > > I also get other errors at program exit. > > Thanks for any he

Error when exiting program

2011-02-18 Thread Joel Christensen
I'm using some one else's bindings to a C library. The problem seems to be limited to D2 programs. Error as follows: An exception was thrown while finalizing an instance of class jec2.bmp.Bmp I also get other errors at program exit. Thanks for any help. :-)

Re: Verify tuple is a tuple of class objects?

2011-02-18 Thread Stewart Gordon
On 18/02/2011 21:22, Steven Schveighoffer wrote: template VerifyTuple(Types...) { static if(Types.length == 0) enum bool VerifyTuple = true; else enum bool VerifyTuple == is(Type : Object) && VerifyTuple!(Types[1..$]); You have two typos there. Corrected version: enum bool VerifyTuple =

Re: using a binary tree container

2011-02-18 Thread Stewart Gordon
On 11/02/2011 12:30, Dominic Jones wrote: Would that not be constructing an associated array? Whilst an associated array would do the job, there is no value for the "key:value" pair, just a list of keys. In the C++ STL there are the "set" and "map" containers. I want something like "set". Domi

Re: Read non-UTF8 file

2011-02-18 Thread Stewart Gordon
On 13/02/2011 21:49, Nrgyzer wrote: It compiles and works as long as the returned char-array/string of f.readLine() doesn't contain non-UTF8 character(s). If it contains such chars, writeln() doesn't write anything to the console. Is there any chance to read such files? Please post sample in

Re: datetime fails with undefined reference

2011-02-18 Thread Jonathan M Davis
On Friday, February 18, 2011 16:27:23 Russel Winder wrote: > As noted in my earlier email on the other list, I too got this problem. > Fromn what I can tell 1.066 and 2.051 have dmd.conf files but there is > no such thing in the 1.067 and 2.052 distributions. So the "out of the > box" configuratio

Re: Proxy sorting

2011-02-18 Thread bearophile
> Thank you for your answers. Second try, it doesn't work yet, I'm looking for > the problem: Third try, this seems to work: import std.stdio, std.array, std.algorithm, std.range; struct IndirectArray(Tdata, Tindexes) { Tdata[] data; Tindexes[] indexes; bool empty() { return indexe

Re: datetime fails with undefined reference

2011-02-18 Thread Russel Winder
On Sat, 2011-02-19 at 00:27 +, Russel Winder wrote: > As noted in my earlier email on the other list, I too got this problem. > Fromn what I can tell 1.066 and 2.051 have dmd.conf files but there is > no such thing in the 1.067 and 2.052 distributions. So the "out of the > box" configuration d

Re: datetime fails with undefined reference

2011-02-18 Thread Russel Winder
As noted in my earlier email on the other list, I too got this problem. Fromn what I can tell 1.066 and 2.051 have dmd.conf files but there is no such thing in the 1.067 and 2.052 distributions. So the "out of the box" configuration does seem to be "broken". > That should be in the dmd.conf in dm

Re: Proxy sorting

2011-02-18 Thread bearophile
Steven Schveighoffer: > I think opAssign is incorrect. Silly me :-) > My suggestion would be to create a bidirectional proxy range that uses a > supplemental array to determine where the "next/previous" element is (i.e. > the index array). Should be pretty simple. Then just pass this to so

Re: Verify tuple is a tuple of class objects?

2011-02-18 Thread Simen kjaeraas
bearophile wrote: I don't know if there is a way to write IsClass() in a shorter way, like a "lambda template". No such thing, sadly. I have suggested it before, and would love to see such a feature. -- Simen

Re: Finding out if T is a specialization of another template

2011-02-18 Thread Lars T. Kyllingstad
On Fri, 18 Feb 2011 20:37:38 +, Sean Eskapp wrote: > == Quote from Lars T. Kyllingstad (public@kyllingen.NOSPAMnet)'s article >> On Fri, 18 Feb 2011 17:16:02 +, Sean Eskapp wrote: >> > I was given this code, to check if Y is a specialization of Bar. How >> > does it work? >> > >> > class B

Re: Verify tuple is a tuple of class objects?

2011-02-18 Thread Andrej Mitrovic
Can anyone explain to me why this throws: class Foo() { } void main() { static if (is(Foo == class)) { } else { static assert(0); } }

Re: datetime fails with undefined reference

2011-02-18 Thread Jonathan M Davis
On Friday, February 18, 2011 12:29:40 Kai Meyer wrote: > == Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > > > On Friday, February 18, 2011 10:12:09 Kai Meyer wrote: > > > Great news! Worked like a champ. Is there documentation somewhere that > > > I missed? I would love to be able

Re: Verify tuple is a tuple of class objects?

2011-02-18 Thread bearophile
Sean Eskapp: > What I'm trying to do is verify that every element of a tuple is a class type, If you mean a TypeTuple, this is a solution: import std.typetuple: allSatisfy, TypeTuple; template IsClass(T) { enum IsClass = is(T == class); } class Foo {} class Bar {} struct Spam {} alias Typ

Re: Verify tuple is a tuple of class objects?

2011-02-18 Thread Steven Schveighoffer
On Fri, 18 Feb 2011 16:15:16 -0500, Sean Eskapp wrote: Is there a way to "run" a template at compile time, without using a member? What I'm trying to do is verify that every element of a tuple is a class type, and so far, I've been doing this: template VerifyTuple(Type, Types...) { stat

Verify tuple is a tuple of class objects?

2011-02-18 Thread Sean Eskapp
Is there a way to "run" a template at compile time, without using a member? What I'm trying to do is verify that every element of a tuple is a class type, and so far, I've been doing this: template VerifyTuple(Type, Types...) { static assert(is(Type : Object), Type.stringof ~ " is not a cl

Re: Finding out if T is a specialization of another template

2011-02-18 Thread Sean Eskapp
== Quote from Lars T. Kyllingstad (public@kyllingen.NOSPAMnet)'s article > On Fri, 18 Feb 2011 17:16:02 +, Sean Eskapp wrote: > > I was given this code, to check if Y is a specialization of Bar. How > > does it work? > > > > class Bar(T) > > { > > } > > > > void foo(Y)() > > { > > static if

Re: datetime fails with undefined reference

2011-02-18 Thread Kai Meyer
== Quote from Jonathan M Davis (jmdavisp...@gmx.com)'s article > On Friday, February 18, 2011 10:12:09 Kai Meyer wrote: > > Great news! Worked like a champ. Is there documentation somewhere that I > > missed? I would love to be able to answer these questions on my own. I've > > been stumped on this

Re: __stack_chk_guard on Mac OSX

2011-02-18 Thread Jacob Carlborg
On 2011-02-17 22:19, HansR wrote: I followed the directions on http://www.digitalmars.com/d/2.0/dmd-osx.html for the hello.d example and I kept getting an error about __stack_chk_guard. Seems odd. What version of the D compiler are you using and what version of Mac OS X? -- /Jacob Carlborg

Re: datetime fails with undefined reference

2011-02-18 Thread Jonathan M Davis
On Friday, February 18, 2011 11:43:22 Lars T. Kyllingstad wrote: > On Fri, 18 Feb 2011 10:23:41 -0800, Jonathan M Davis wrote: > > On Friday, February 18, 2011 10:12:09 Kai Meyer wrote: > >> Great news! Worked like a champ. Is there documentation somewhere that > >> I missed? I would love to be abl

Re: datetime fails with undefined reference

2011-02-18 Thread Lars T. Kyllingstad
On Fri, 18 Feb 2011 10:23:41 -0800, Jonathan M Davis wrote: > On Friday, February 18, 2011 10:12:09 Kai Meyer wrote: >> Great news! Worked like a champ. Is there documentation somewhere that >> I missed? I would love to be able to answer these questions on my own. >> I've been stumped on this one

Re: Opt-out polymorphism?

2011-02-18 Thread bearophile
Stewart Gordon: > Then you're not overriding at all. You're just declaring a function in the > derived class > that happens to have the same name. I think Sean refers to the second usage of "new" in C#: http://msdn.microsoft.com/en-us/library/51y09td4%28v=vs.71%29.aspx Bye, bearophile

Re: datetime fails with undefined reference

2011-02-18 Thread Jonathan M Davis
On Friday, February 18, 2011 10:12:09 Kai Meyer wrote: > Great news! Worked like a champ. Is there documentation somewhere that I > missed? I would love to be able to answer these questions on my own. I've > been stumped on this one for a week :( That should be in the dmd.conf in dmd.2.052.zip. If

Re: datetime fails with undefined reference

2011-02-18 Thread Kai Meyer
Great news! Worked like a champ. Is there documentation somewhere that I missed? I would love to be able to answer these questions on my own. I've been stumped on this one for a week :(

Re: Finding out if T is a specialization of another template

2011-02-18 Thread Lars T. Kyllingstad
On Fri, 18 Feb 2011 17:16:02 +, Sean Eskapp wrote: > I was given this code, to check if Y is a specialization of Bar. How > does it work? > > class Bar(T) > { > } > > void foo(Y)() > { > static if (is(Y Z == Bar!Z)) > { > // Here, Z is now an alias to whichever type Bar is //

Re: datetime fails with undefined reference

2011-02-18 Thread Lars T. Kyllingstad
On Fri, 18 Feb 2011 16:38:19 +, Kai Meyer wrote: > I can't seem to use std.datetime at all. I get undefined reference on > whether I use a StopWatch, or if I just try to compile the unittest. All > I have to do is declare a StopWatch: > > import std.stdio; > import std.datetime; > > void mai

Re: Opt-out polymorphism?

2011-02-18 Thread Stewart Gordon
On 13/02/2011 21:34, Sean Eskapp wrote: Is there a way to specify that a function is nonvirtual, but can still be "overriden" in base classes? e.g. Then you're not overriding at all. You're just declaring a function in the derived class that happens to have the same name. As such, it seems

Finding out if T is a specialization of another template

2011-02-18 Thread Sean Eskapp
I was given this code, to check if Y is a specialization of Bar. How does it work? class Bar(T) { } void foo(Y)() { static if (is(Y Z == Bar!Z)) { // Here, Z is now an alias to whichever type Bar is // instantiated with. } else { // Z is invalid here.

datetime fails with undefined reference

2011-02-18 Thread Kai Meyer
I can't seem to use std.datetime at all. I get undefined reference on whether I use a StopWatch, or if I just try to compile the unittest. All I have to do is declare a StopWatch: import std.stdio; import std.datetime; void main() { StopWatch sw; } This fails to compile: [kai@worky ~]$ dmd

Re: Proxy sorting

2011-02-18 Thread Steven Schveighoffer
On Fri, 18 Feb 2011 08:08:22 -0500, bearophile wrote: This is a RosettaCode simple task: http://rosettacode.org/wiki/Sort_disjoint_sublist#D Given a list of values and a set of integer indices into that value list, sort the values at the given indices, but preserving the values at indice

Proxy sorting

2011-02-18 Thread bearophile
This is a RosettaCode simple task: http://rosettacode.org/wiki/Sort_disjoint_sublist#D Given a list of values and a set of integer indices into that value list, sort the values at the given indices, but preserving the values at indices outside the set of those to be sorted. Example input: val

Re: Checking if something is a template specialization?

2011-02-18 Thread Sean Eskapp
== Quote from Lars T. Kyllingstad (public@kyllingen.NOSPAMnet)'s article > On Fri, 18 Feb 2011 02:02:51 +, Sean Eskapp wrote: > > If I have > > > > class Bar(T) > > { > > } > > > > void foo(Y)() > > { > >... > > } > > > > Is there a way to check inside foo() that Y is in some way an > > ins

Re: BigInt problem

2011-02-18 Thread Don
tsukikage wrote: Please see source in attachment. The output is M2 M3 M5 M7 M13 M17 M19 M31 M61 M89 M107 M127 M521 M607 M1279 M2203 M2281 M3217 M4253 M4423 *** M9689*** M9941 M11213 M19937 *** M21701*** M23209 It missed 2 Mersenne Primes 9689 & 21701. Is it my program bug or bigint broken?

Re: Checking if something is a template specialization?

2011-02-18 Thread Lars T. Kyllingstad
On Fri, 18 Feb 2011 02:02:51 +, Sean Eskapp wrote: > If I have > > class Bar(T) > { > } > > void foo(Y)() > { >... > } > > Is there a way to check inside foo() that Y is in some way an > instantiation of Bar? Is there a way to find WHICH instantiation it is? void foo(Y)() { static