feature request: __traits(getTemplate, A!T) => A; __traits(getTemplateArguments, A!(T,"foo")) => (T,"foo")
Timothee Cour
thelastmammoth at gmail.com
Sat Jun 22 16:57:03 PDT 2013
On Sat, Jun 22, 2013 at 4:18 PM, anonymous <anonymous at example.com> wrote:
> On Saturday, 22 June 2013 at 23:03:17 UTC, Dicebot wrote:
>
>> http://dpaste.1azy.net/**22d5eee2 <http://dpaste.1azy.net/22d5eee2>
>>
>> ------------------------------**------
>>
>> import std.traits;
>>
>> template getTemplate(T)
>> {
>> static if (is(T == TI!TP, alias TI, TP))
>>
>
> alias! Of course!
>
>
> {
>> alias getTemplate = TI;
>> }
>> else
>> static assert (false);
>> }
>>
>
> Replacing the static if with template specialization makes it shorter:
> template getTemplate(T : TI!TP, alias TI, TP)
> {
> alias getTemplate = TI;
> }
>
great, thanks!
improved to support arbitrary number of a
template getTemplate(T : TI!TP, alias TI, TP...)
{
alias getTemplate = TI;
}
however, indeed seems to work with types only, not functions.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20130622/ddbaa226/attachment.html>
More information about the Digitalmars-d
mailing list