On Friday, 6 May 2016 at 20:01:27 UTC, Alexandru Ermicioi wrote:
Is it possible somehow to convert implicitly a string literal

Not implicitly (well, unless you just use string, ascii is a strict subset of utf-8 anyway), but you could do it explicitly easily.

immutable(ubyte)[] ascii(string s) { return cast(typeof(return)) s; }


Then use it like

ascii("your string")

or make it a template and use ascii!"your string" or "your string".ascii whatever.

You could (and imo should!) also make a struct to hold the new type.

Reply via email to