| |
| Posted by torhu in reply to torhu | PermalinkReply |
|
torhu
| On Tuesday, 27 September 2022 at 22:39:52 UTC, torhu wrote:
> How would I achieve something like this, do I have to turn the aliases into functions?
void _messageBox(string title, int style, T...)(T args)
{
string s = format(args);
/* etc... */
}
alias _messageBox!(APPNAME, SWT.ICON_INFORMATION) info;
alias _messageBox!("Warning", SWT.ICON_WARNING) warning;
alias _messageBox!("Error", SWT.ICON_ERROR) error;
I should mention that I am really looking for a Phobos 2 way of achieving what I currently do, which is this:
void _messageBox(string title, int style)(...)
{
char[] msg;
void f(dchar c) { encode(msg, c); }
doFormat(&f, _arguments, _argptr);
messageBox(cast(string)msg, title, style);
}
|