| 1 |
// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110959 |
| 2 |
// { dg-do compile } |
| 3 |
class ArsdExceptionBase : object.Exception { |
| 4 |
this(string operation, string file = __FILE__, size_t line = __LINE__, Throwable next = null) { |
| 5 |
super(operation, file, line, next); |
| 6 |
} |
| 7 |
} |
| 8 |
|
| 9 |
template ArsdException(alias Type, DataTuple...) { |
| 10 |
static if(DataTuple.length) |
| 11 |
alias Parent = ArsdException!(Type, DataTuple[0 .. $-1]); |
| 12 |
else |
| 13 |
alias Parent = ArsdExceptionBase; |
| 14 |
|
| 15 |
class ArsdException : Parent { |
| 16 |
DataTuple data; |
| 17 |
|
| 18 |
this(DataTuple data, string file = __FILE__, size_t line = __LINE__) { |
| 19 |
this.data = data; |
| 20 |
static if(is(Parent == ArsdExceptionBase)) |
| 21 |
super(null, file, line); |
| 22 |
else |
| 23 |
super(data[0 .. $-1], file, line); |
| 24 |
} |
| 25 |
|
| 26 |
static opCall(R...)(R r, string file = __FILE__, size_t line = __LINE__) { |
| 27 |
return new ArsdException!(Type, DataTuple, R)(r, file, line); |
| 28 |
} |
| 29 |
} |
| 30 |
} |
| 31 |
|
| 32 |
__gshared pr110959 = ArsdException!"Test"(4, "four"); |