On Sunday, 8 May 2016 at 23:49:40 UTC, Ali Çehreli wrote:
On 05/08/2016 04:48 PM, Erik Smith wrote:
On Sunday, 8 May 2016 at 22:37:44 UTC, Dicebot wrote:
On Sunday, 8 May 2016 at 14:11:31 UTC, Ali Çehreli wrote:
E front() {
final switch (index) {
/* static *
On Sunday, 8 May 2016 at 22:37:44 UTC, Dicebot wrote:
On Sunday, 8 May 2016 at 14:11:31 UTC, Ali Çehreli wrote:
E front() {
final switch (index) {
/* static */ foreach (i, arg; Args) {
case i:
return arg;
On Sunday, 8 May 2016 at 14:11:31 UTC, Ali Çehreli wrote:
On 05/05/2016 11:08 PM, Dicebot wrote:
> Unless parameter list is very (very!) long, I'd suggest to
simply copy
> it into a stack struct. Something like this:
>
> auto toInputRange (T...) (T args)
> {
> struct Range
> {
>
On Friday, 6 May 2016 at 05:20:50 UTC, Ali Çehreli wrote:
On 05/05/2016 10:00 PM, Erik Smith wrote:
Is there an existing way to adapt a parameter pack to an input
range? I
would like to construct an array with it. Example:
void run(A...) (A args) {
Array!int a(toInputRange(args));
}
Is there an existing way to adapt a parameter pack to an input
range? I would like to construct an array with it. Example:
void run(A...) (A args) {
Array!int a(toInputRange(args));
}
On Thursday, 5 May 2016 at 16:12:40 UTC, Steven Schveighoffer
wrote:
On 5/5/16 12:10 AM, Erik Smith wrote:
I want to have a struct template auto instantiate when the
template
parameters are defaulted or missing. Example:
struct Resource(T=int) {
static auto create() {return Resource(null
I want to have a struct template auto instantiate when the
template parameters are defaulted or missing. Example:
struct Resource(T=int) {
static auto create() {return Resource(null);}
this(string s) {}
}
auto resource = Resource.create;
As a plain struct it works, but not as a templa
You're close.
An `alias` template parameter can be any symbol, including a
template. But you can't pass in a template as a runtime
parameter, so having `F f` in your parameters list is wrong
(there's nothing to pass anyway; you already have the template,
which is F).
static void call(alias
I don't think it's possible to call a vararg function whose
number of arguments is only known at runtime, for the same
reasons it is impossible in C [1].
Your switch statement is probably the best you can do, other
than rewriting the API to not use varargs (which, depending on
what the functi
C++ has template templates. I'm not sure how to achieve the same
effect where (in example below) the template function myVariadic
is passed to another function.
void myVaridatic(A...)(A a) {}
static void call(alias F,A...)(F f,A a) {
f(a);
}
void f
On Monday, 2 May 2016 at 18:56:59 UTC, Stefan Koch wrote:
On Monday, 2 May 2016 at 18:22:52 UTC, Erik Smith wrote:
Is there way to construct an "argument pack" from a non-static
array (like the switch below)? I need to transport a variadic
call through a void*.
switch (a.length) {
case 1:
Is there way to construct an "argument pack" from a non-static
array (like the switch below)? I need to transport a variadic
call through a void*.
switch (a.length) {
case 1: foo(a[1]); break;
case 2: foo(a[1], a[2]); break;
case 3: foo(a[1], a[2], a[3]); break;
...
}
I tried to combine the two solutions (Basile with the wrapper,
Marco with the struct initializer support) but it didn't work.
The struct initializer is not a array literal (seems obvious
now). I might go with the 2nd but it's pretty heavy just to get
the size.
Thanks.
struct S {
int a
Is there a way to initialize a static array and have it's size
inferred (and that works for arrays of structs using braced
literals)? This would make it easier to maintain longer static
array definitions. The code below doesn't work when removing the
array size even though the array is declar
14 matches
Mail list logo