Template function alias that leaves out the last type parameter

torhu torhu at yahoo.com
Tue Sep 27 22:46:30 UTC 2022


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?
>
> ```d
> 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:
```d
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);
}
```


More information about the Digitalmars-d-learn mailing list