Template parameter deduction for constructors?
Timon Gehr
timon.gehr at gmx.ch
Sun Apr 14 08:47:47 PDT 2013
On 04/13/2013 01:00 AM, bearophile wrote:
> This is one of the few C++14 core language proposals that seem
> interesting for D:
>
> http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2013/n3602.html
>
> The purpose of this idea is to avoid the helper functions that are
> currently used in D to build template structs/classes. Even if this
> feature is restricted to only a subset of all the templated
> structs/classes it seems useful to avoid some boilerplate code.
>
> Is this idea adaptable to D?
>
> Bye,
> bearophile
I think the differences to be accounted for are basically that D has
n-ary default constructors, static opCall, and static if. Furthermore,
with IFTI, it is possible to only specify the prefix of the template
arguments.
---
struct S(T...){
T data;
}
S(1,2,3); // ?
S!double(1,2,3); // ?
---
struct S(T...){
T data;
static if(T.length){
this(T x){ }
}
}
S(1,2,3); // ?
---
struct S(T...){
static opCall(T)(T args){ }
}
S(1,2,3); // ?
---
More information about the Digitalmars-d
mailing list