Re: Compile time foreach with switch

2017-04-21 Thread Johan Fjeldtvedt via Digitalmars-d-learn
On Friday, 21 April 2017 at 19:17:32 UTC, Adam D. Ruppe wrote: On Friday, 21 April 2017 at 19:09:25 UTC, Johan Fjeldtvedt wrote: void foo(string s) { enum es = tuple("a", "b", "c"); switch (s) { foreach (e; es) { case e: writeln("matched ", e); break

Compile time foreach with switch

2017-04-21 Thread Johan Fjeldtvedt via Digitalmars-d-learn
I was a bit surprised to find out (https://forum.dlang.org/post/csiwyetjkttlxxnwn...@forum.dlang.org) that compile time foreach-loops can be used inside switch-statements. I tried the following: import std.stdio; import std.typecons; void foo(string s) { enum es = tuple("a", "b", "c");

Re: Forwarding calls to objects of another type

2017-04-19 Thread Johan Fjeldtvedt via Digitalmars-d-learn
On Tuesday, 11 April 2017 at 02:01:19 UTC, Nicholas Wilson wrote: On Monday, 10 April 2017 at 21:27:34 UTC, Basile B. wrote: 2) This is about the reduce templates. As I've commented, I can't use a template lambda with reduce, but I can use a lambda taking ints as arguments. Why is this? The err

Re: Forwarding calls to objects of another type

2017-04-19 Thread Johan Fjeldtvedt via Digitalmars-d-learn
On Monday, 10 April 2017 at 21:27:34 UTC, Basile B. wrote: On Monday, 10 April 2017 at 21:04:10 UTC, Johan Fjeldtvedt wrote: [...] One way: [...] Thanks for the reply. The traits way of doing it seems to be what I want. :) [...] [...]

Forwarding calls to objects of another type

2017-04-10 Thread Johan Fjeldtvedt via Digitalmars-d-learn
I have a couple of questions related to the following code: https://gist.github.com/Jaffe-/b027287a884fc2e173a65601ec242676 1) This is a very simplified example, but what I'm trying to do here is to call `foo` on each object in `Container.ss` contains when `foo` is called, and likewise for `ba