On Tuesday, 2 May 2017 at 17:08:11 UTC, Juanjo Alvarez wrote:
Example:
struct S {
int someState;
void some_foo() { return this. someState;}
void delegate() foo;
void enable() {
foo = _foo;
}
}
unittest {
S s;
s.someState = 1;
enable();
s.someState = 2;
assert(foo ==
Hi!
I would like to have a "proxy" delegate, let's call it "foo" that
could point to a method or another, let's call them "fast_foo" or
"slow_foo" on the same object. This way depending on some
conditions I could switch at runtime from one set of methods to
others with a "switchFoo(" fast")
Thanks to both, I got it. Type templates for generic types, and
alias for other things knowing that the instantiation is by
symbol.
Yes, the "alias this" in my message was a (double) brainfart, I
actually wanted to write "alias template".
In this case both functions had the same assembler
Hi!
With "alias this" accepting runtime variables I'm struggling to
understand the difference between a generic function with an
"alias this" parameter and another one with a "runtime" parameter
of template type.
Example:
// example code
import std.stdio: writeln;
void
Hi,
Newbie question:
void foo(S)(S oneparam){}
void foo(S)(S oneparam, int anotherParam){}
alias fooStr = foo!string;
Gives:
Error: template test.foo matches more than one template
declaration:
How could I fix it so the alias aliases one of the two versions?
Also, why can't fooStr be an
On Wednesday, 11 June 2014 at 06:50:08 UTC, Kagamin wrote:
debug version = DebugOrUnittest;
else version(unittest)version = DebugOrUnittest;
version(DebugOrUnittest) { static
assert(false,DebugOrUnittest); }
I like this option more. I didn't knew you could assign to
version.
Thanks,
On Tuesday, 10 June 2014 at 14:06:58 UTC, bearophile wrote:
Juanjo Alvarez:
Probably I pretty simple question, how could I mark some code
to be compiled when in debug OR unittest mode? (or both, ||)
At first I tough I could do:
version(unittest, debug) {}
You can define a enum boolean
Hi,
Probably I pretty simple question, how could I mark some code to
be compiled when in debug OR unittest mode? (or both, ||)
At first I tough I could do:
version(unittest, debug) {}
but this doesn't work.
Then I tried to define a new version:
version(DebugOrUnittest)
{
version =