On Sunday, 8 May 2016 at 14:11:31 UTC, Ali Çehreli wrote:
I like Alex Parrill's only() solution but it allocates a
dynamic array as well by doing the equivalent of [args] in the
guts of its implementation.
No it does not.
The constructor does `this.data = [values];`, but `this.data` is
a fix
On Monday, 9 May 2016 at 12:36:00 UTC, Ali Çehreli wrote:
On 05/09/2016 03:44 AM, Dicebot wrote:
> Ali version generates a compile-time switch for index
I think it's a run-time switch, generated by a compile-time
foreach:
E front() {
final switch (index) {// <-- RUNTI
On 05/09/2016 03:44 AM, Dicebot wrote:
> Ali version generates a compile-time switch for index
I think it's a run-time switch, generated by a compile-time foreach:
E front() {
final switch (index) {// <-- RUNTIME
/* static */ foreach (i, arg; Args) { // <-- COMPI
On Sunday, 8 May 2016 at 23:48:01 UTC, Erik Smith wrote:
Thanks! The static array version works for me too. It would
be good to understand more about what is going on. It looks
like the cost of the static array is an extra copy for each
element. Maybe there is still a way to avoid that.
T
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 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 */ foreach (i, arg; Args) {
case i:
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:
E front() {
final switch (index) {
/* static */ foreach (i, arg; Args) {
case i:
return arg;
}
}
}
AFAIK, this will do fu
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 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 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
> {
> T args;
> size_t index;
>
> T[0] front
On Friday, 6 May 2016 at 05:00:48 UTC, 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));
}
Use std.range.only: http://dlang.org/phobos/st
On Friday, 6 May 2016 at 06:08:24 UTC, 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
{
T args;
size_t index;
T[0] front () { ret
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
{
T args;
size_t index;
T[0] front () { return args[index]; }
void popFront () { ++index;
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));
}
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));
}
Inspired by my DConf 2016 talk ;) here is a fiber-based Inpu
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));
}
Just initialize an array with the arguments:
void run(A...)
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));
}
18 matches
Mail list logo