OPTLINK checkpoint(256)

2015-07-20 Thread Lemonfiend via Digitalmars-d-learn
I was still using 2.066.1. When I try to build using 2.067.0 or 2.067.1 I get: Linking... checkpoint(256) --- errorlevel 1 with an Unexpected OPTLINK Termination popup which lists a bunch of registers. I'm not sure how to proceed..

Static function template

2015-05-07 Thread Lemonfiend via Digitalmars-d-learn
Is it not possible to have a static function template with the same name as the non-static version? struct S { int i; auto foo(T)(int j) { i=j; } static auto foo(T)(int j) { S s; s.foo!T(j); return s; } } void main() { auto s =

Re: Static function template

2015-05-07 Thread Lemonfiend via Digitalmars-d-learn
On Thursday, 7 May 2015 at 10:43:28 UTC, Daniel Kozak wrote: On Thursday, 7 May 2015 at 10:39:09 UTC, Daniel Kozák wrote: On Thu, 07 May 2015 10:33:44 + Vadim Lopatin via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: struct S { int i; auto foo2(T)(int j) {

Template mixin enum stringof

2014-12-10 Thread Lemonfiend via Digitalmars-d-learn
Consider the following: --- enum Foo { BAR, } mixin template S(string s_) { enum s = s_; } void main() { mixin S!(Foo.BAR.stringof); // Error: identifier 'stringof' of 'Foo.BAR.stringof' is not defined enum e = Foo.BAR.stringof; mixin S!(e); // works fine } --- Why

Re: Template mixin enum stringof

2014-12-10 Thread Lemonfiend via Digitalmars-d-learn
On Wednesday, 10 December 2014 at 12:08:34 UTC, ketmar via Digitalmars-d-learn wrote: On Wed, 10 Dec 2014 11:52:11 + Lemonfiend via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: Consider the following: --- enum Foo { BAR, } mixin template S(string s_) { enum s

Re: Template mixin enum stringof

2014-12-10 Thread Lemonfiend via Digitalmars-d-learn
On Wednesday, 10 December 2014 at 12:57:07 UTC, Daniel Kozák via Digitalmars-d-learn wrote: V Wed, 10 Dec 2014 12:35:44 + Lemonfiend via Digitalmars-d-learn digitalmars-d-learn@puremagic.com napsáno: On Wednesday, 10 December 2014 at 12:08:34 UTC, ketmar via Digitalmars-d-learn wrote

Re: Template mixin enum stringof

2014-12-10 Thread Lemonfiend via Digitalmars-d-learn
On Wednesday, 10 December 2014 at 12:57:16 UTC, ketmar via Digitalmars-d-learn wrote: On Wed, 10 Dec 2014 12:35:44 + Lemonfiend via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wednesday, 10 December 2014 at 12:08:34 UTC, ketmar via Digitalmars-d-learn wrote: On Wed

Re: Template mixin enum stringof

2014-12-10 Thread Lemonfiend via Digitalmars-d-learn
On Wednesday, 10 December 2014 at 14:25:30 UTC, ketmar via Digitalmars-d-learn wrote: On Wed, 10 Dec 2014 13:58:20 + Lemonfiend via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: On Wednesday, 10 December 2014 at 12:57:16 UTC, ketmar via Digitalmars-d-learn wrote: On Wed

Re: alias overloaded function template

2014-11-12 Thread Lemonfiend via Digitalmars-d-learn
The problem is not the alias. The error message is about using the same identifier for two different things: C:\...\temp_0186F968.d(13,1): Error: declaration foo(T)(T t, int i) is already defined. I'm not sure what is giving you that particular error. Without the alias it compiles and runs

How to use map?

2014-11-11 Thread Lemonfiend via Digitalmars-d-learn
I'm trying to do something simple like creating an array of struct S from a float array via map: --- void main() { float[] vals = [1.1, 2.1, 3.1, 4.1]; import std.algorithm: map; auto arr = vals.map!`S(a)`.array; writeln(arr); } struct S(T) { T t; } ---

Re: How to use map?

2014-11-11 Thread Lemonfiend via Digitalmars-d-learn
The code you were trying to write: struct Foo(T) { T t; } void main() { import std.stdio, std.algorithm, std.array; float[] vals = [1.1, 2.1, 3.1, 4.1]; auto arr = vals.map!(Foo!float).array; arr.writeln; } Sorry, my example had an unneeded template. Simply this (and also

Re: How to use map?

2014-11-11 Thread Lemonfiend via Digitalmars-d-learn
Oh, no it doesn't. My bad. It was all about !(Foo) vs !(`Foo(a)`). Is there somewhere I can read more about this?

Re: How to use map?

2014-11-11 Thread Lemonfiend via Digitalmars-d-learn
On Tuesday, 11 November 2014 at 15:53:37 UTC, Marc Schütz wrote: Don't know whether it's documented, but it's a consequence of using string mixins. unaryFun (which is used internally by map) is implemented this way: auto unaryFun(ElementType)(auto ref ElementType __a) {

alias overloaded function template

2014-11-11 Thread Lemonfiend via Digitalmars-d-learn
D is fine with alias this overloaded function: --- void foo(int t) {} void foo(int t, int i) {} alias bar = foo; --- But isn't as happy aliasing these function templates: --- void foo(T)(T t) {} void foo(T)(T t, int i) {} alias bar = foo!int; --- Is there some way/other syntax to make an

Bug when overload function in multiple modules?

2014-08-27 Thread Lemonfiend via Digitalmars-d-learn
I get: src\app.d(19): Error: None of the overloads of 'foo' are callable using argument types (C3), candidates are: src\app.d(28):main.foo(C1 c) src\app.d(38):main.foo(C2 c) It does work when I explicitly import c3.foo. --- file app.d module app; import std.stdio; import c3;

SList: How do I use linearRemove?

2014-06-26 Thread Lemonfiend via Digitalmars-d-learn
--- module main; void main() { struct Tree { int apples; } import std.container; SList!Tree list; Tree tree = Tree(5); list.insert(tree); //list.linearRemove(tree); // -- Error. What is the correct way? } ---

Re: SList: How do I use linearRemove?

2014-06-26 Thread Lemonfiend via Digitalmars-d-learn
linearRemove is linear, so I think it accepts a range. Perhaps the once range is enough. I cannot find once in the docs. Did you mean std.range.only? Error: function std.container.SList!(Tree).SList.linearRemove (Range r) is not callable using argument types (OnlyResult!(Tree, 1u))

Re: SList: How do I use linearRemove?

2014-06-26 Thread Lemonfiend via Digitalmars-d-learn
unittest { auto s = SList!int(1, 2, 3, 4, 5); auto r = s[]; popFrontN(r, 3); auto r1 = s.linearRemove(r); assert(s == SList!int(1, 2, 3)); assert(r1.empty); } This works: auto s = SList!int(1, 2, 3, 4, 5); auto r = s[]; popFrontN(r, 1); auto r1 = s.linearRemove(r); This