Thread overview | |||||
---|---|---|---|---|---|
|
May 16, 2009 Partial specialisation: howto? | ||||
---|---|---|---|---|
| ||||
Attachments: | Hi Everybody, Please have a look at the appended sucky code. Obv. the createHandlerCode function is a pain in the back side for extending this system; I want multiple different partially specialised implementations. So whats the syntax for doing partial specialisation? Damed if I can work it out. ================== enum EHandlerType { eMsgRangeHdlr, eMsgHdlr, eCmdIdHdlr } template createHandlerCode(T ...) { string format() { static if(T[0]._type == EHandlerType.eMsgRangeHdlr) return createMessageRangeHandler!(T).format(); else static if(T[0]._type == EHandlerType.eMsgHdlr) return createMessageHandler!(T).format(); else static if(T[0]._type == EHandlerType.eCmdIdHdlr) return createCommandIdHandler!(T).format(); else static assert(false, "handler type not handled"); } } struct msgRangeHdlr(uint msgIdFirst, uint msgIdLast, string responseMethod) { invariant EHandlerType _type = EHandlerType.eMsgRangeHdlr; invariant string _msgIdFirst = std.metastrings.ToString!(msgIdFirst); invariant string _msgIdLast = std.metastrings.ToString!(msgIdLast); invariant string _responseMethod = responseMethod; } struct msgHdlr(uint msgId, string responseMethod) { invariant EHandlerType _type = EHandlerType.eMsgHdlr; invariant string _msgId = std.metastrings.ToString!(msgId); invariant string _responseMethod = responseMethod; } struct cmdIdHdlr(uint cmdId, string responseMethod) { invariant EHandlerType _type = EHandlerType.eCmdIdHdlr; invariant string _cmdId = std.metastrings.ToString!(cmdId); invariant string _responseMethod = responseMethod; } - -- My enormous talent is exceeded only by my outrageous laziness. |
May 16, 2009 Re: Partial specialisation: howto? | ||||
---|---|---|---|---|
| ||||
Posted in reply to div0 | div0 wrote:
> Hi Everybody,
Greetings.
While I am not able to help with your problem, I would like
to point you to digitalmars.D.learn, which is for questions
about how the language works. digitalmars.D.announce is for
announcements.
--
Simen
|
May 17, 2009 Re: Partial specialisation: howto? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Simen Kjaeraas Attachments: | Simen Kjaeraas wrote:
> div0 wrote:
>> Hi Everybody,
>
> Greetings.
>
> While I am not able to help with your problem, I would like to point you to digitalmars.D.learn, which is for questions about how the language works. digitalmars.D.announce is for announcements.
>
> --
> Simen
balls. sry.
- --
My enormous talent is exceeded only by my outrageous laziness.
|
Copyright © 1999-2021 by the D Language Foundation