On Sat, 10 Dec 2011 02:42:30 -0500, Andrew Wiley
wrote:
On Sat, Dec 10, 2011 at 1:23 AM, Andrew Wiley
wrote:
Is there a syntax that allows me to specify arguments to a templated
constructor for a struct? The intuitive way looks like this, but it
doesn't work.
---
struct Test {
this
You can cheat with __ctor:
Test test = Test.__ctor!(int, true)(5);
On Sat, Dec 10, 2011 at 5:38 AM, Trass3r wrote:
>> Looks like I can work around it by doing this:
>> ---
>> template makeTest(T, bool b) {
>> static if((b && something) || (!b && somethingElse)) {
>> alias Test makeTest;
>> }
>> else static assert(0, "some error message");
>> }
>>
Looks like I can work around it by doing this:
---
template makeTest(T, bool b) {
static if((b && something) || (!b && somethingElse)) {
alias Test makeTest;
}
else static assert(0, "some error message");
}
struct Test {
private:
this(T)(T info) {
}
}
void main() {
On Sat, Dec 10, 2011 at 1:23 AM, Andrew Wiley wrote:
> Is there a syntax that allows me to specify arguments to a templated
> constructor for a struct? The intuitive way looks like this, but it
> doesn't work.
>
> ---
> struct Test {
> this(T, bool b)(T info) if((b && something ) || (!b &&
Is there a syntax that allows me to specify arguments to a templated
constructor for a struct? The intuitive way looks like this, but it
doesn't work.
---
struct Test {
this(T, bool b)(T info) if((b && something ) || (!b && somethingElse)) {
}
}
void main() {