On Wednesday, 2 March 2016 at 20:39:57 UTC, Adam D. Ruppe wrote:
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote:
Is it by design or is it a bug?
And, if it is by design, what is the reason for that?
That's by design. It allows you to override names from a
template mixin like
Dne 2.3.2016 v 21:39 Adam D. Ruppe via Digitalmars-d-learn napsal(a):
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote:
Is it by design or is it a bug?
And, if it is by design, what is the reason for that?
That's by design. It allows you to override names from a template
mixi
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote:
Is it by design or is it a bug?
And, if it is by design, what is the reason for that?
That's by design. It allows you to override names from a template
mixin like inheritance but no runtime cost.
Read my tip of the week here to
On Wednesday, 2 March 2016 at 14:50:15 UTC, Adrian Matoga wrote:
On Wednesday, 2 March 2016 at 14:36:59 UTC, Daniel Kozak wrote:
OK maybe this one:
template AddField(T) {
T b;
this(Args...)(T b, auto ref Args args)
{
this.b = b;
this(args);
}
this(int a) {
On Wednesday, 2 March 2016 at 14:36:59 UTC, Daniel Kozak wrote:
OK maybe this one:
template AddField(T) {
T b;
this(Args...)(T b, auto ref Args args)
{
this.b = b;
this(args);
}
this(int a) {
this.a = a;
}
}
struct Bar {
int a;
mixin Add
On Wednesday, 2 March 2016 at 13:18:23 UTC, Adrian Matoga wrote:
On Wednesday, 2 March 2016 at 12:48:47 UTC, Daniel Kozak wrote:
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga
wrote:
(...)
You can use string mixins:
template AddField(T) {
enum AddField = T.stringof ~ ` b;
On Wednesday, 2 March 2016 at 12:48:47 UTC, Daniel Kozak wrote:
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote:
(...)
You can use string mixins:
template AddField(T) {
enum AddField = T.stringof ~ ` b;
this(Args...)(` ~ T.stringof ~ ` b, auto ref Args args)
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote:
I can do this:
struct Foo {
int a;
string b;
this(int a) { this.a = a; }
this(Args...)(string b, auto ref Args args) { this.b = b;
this(args); }
}
unittest {
auto foo1 = Foo(5);
auto foo2
On Wednesday, 2 March 2016 at 12:27:04 UTC, Adrian Matoga wrote:
I can do this:
struct Foo {
int a;
string b;
this(int a) { this.a = a; }
this(Args...)(string b, auto ref Args args) { this.b = b;
this(args); }
}
unittest {
auto foo1 = Foo(5);
auto foo2
I can do this:
struct Foo {
int a;
string b;
this(int a) { this.a = a; }
this(Args...)(string b, auto ref Args args) { this.b = b;
this(args); }
}
unittest {
auto foo1 = Foo(5);
auto foo2 = Foo("foo", 15);
}
However, the following code is invalid:
mix
10 matches
Mail list logo