Version D 2.062
http://dlang.org/template.html#TemplateAliasParameter
Is is said in the documentation that is's possible but i get
compile time error.
template GetString(alias Arg)
{
enum string GetString = Arg.stringof;
}
void main(string[] argv)
{
writeln(GetString!1234);
ref2401:
template GetString(alias Arg)
{
enum string GetString = Arg.stringof;
}
...
writeln(GetString!int); // Error: template instance
Template alias arguments don't yet accept built-in types as int.
It will be fixed.
Bye,
bearophile
On Thursday, 9 May 2013 at 10:59:02 UTC, ref2401 wrote:
Version D 2.062
http://dlang.org/template.html#TemplateAliasParameter
Is is said in the documentation that is's possible but i get
compile time error.
template GetString(alias Arg)
{
enum string GetString = Arg.stringof;
}
void
On Thursday, 9 May 2013 at 11:19:38 UTC, bearophile wrote:
It will be fixed.
Ugh, proof-link? I have always thought it is by design and that
actually makes sense.
On Thu, 09 May 2013 06:58:57 -0400, ref2401 refacto...@gmail.com wrote:
Version D 2.062
http://dlang.org/template.html#TemplateAliasParameter
Is is said in the documentation that is's possible but i get compile
time error.
template GetString(alias Arg)
{
enum string GetString =
On Thursday, 9 May 2013 at 12:09:03 UTC, Dicebot wrote:
On Thursday, 9 May 2013 at 11:19:38 UTC, bearophile wrote:
It will be fixed.
Ugh, proof-link? I have always thought it is by design and that
actually makes sense.
AFAIK, there is no plan for fix. The behavior is currently a part
of
Steven Schveighoffer:
Do you have evidence of an official statement to the contrary?
Here I don't have evidence, just faith :-)
Bye,
bearophile
On Thursday, 9 May 2013 at 13:27:35 UTC, Steven Schveighoffer
wrote:
template GetString(T) if (is(T == int) || is(T == float) || ...)
{
enum string GetString = T.stringof;
}
Current idiomatic D way to handle both built-in types and symbols
looks like this:
template Hello(T...)
if
Kenji Hara:
AFAIK, there is no plan for fix. The behavior is currently a
part of language design.
Considering matters of D semantic uniformity, and the code shown
by Dicebot:
template Hello(T...)
if (T.length == 1)
{
static if (is(T[0]))
// ...
else
// ...
}
On Thu, 09 May 2013 09:38:29 -0400, Dicebot m.stras...@gmail.com wrote:
On Thursday, 9 May 2013 at 13:27:35 UTC, Steven Schveighoffer wrote:
template GetString(T) if (is(T == int) || is(T == float) || ...)
{
enum string GetString = T.stringof;
}
Current idiomatic D way to handle both
Feels like I am the only one who wants to restrict rules, not
relax them =/
But, erm, you don't need alias accepting literals for old syntax!
Strings are valid as template value parameters:
http://dpaste.1azy.net/54e5d3f2
On Thu, 09 May 2013 10:00:45 -0400, Dicebot m.stras...@gmail.com wrote:
Feels like I am the only one who wants to restrict rules, not relax them
=/
But, erm, you don't need alias accepting literals for old syntax!
Strings are valid as template value parameters:
12 matches
Mail list logo