Postfix string literal alternative suggestion

Janice Caron caron800 at googlemail.com
Sat Feb 9 10:16:35 PST 2008


On 09/02/2008, Edward Diener <eddielee_no_spam_here at tropicsoft.com> wrote:
> then one can easily specify the template type using the notation
> suggested by me to coerce a string literal to the preferred type without
> having to know the type of the template parameter.

But you can do that anyway

    void f(C)()
    {
        invariant(C)[] s = "hello world";
        /*...*/
    }

The literal will be coerced, and s will be of the correct type. No
suffix is needed because this is an assignment statement. You would
need a suffix in an arbitrary expression, but you don't need one in an
assignment statement, so all you have to do is break your code up a
bit more.



More information about the Digitalmars-d mailing list