Postfix string literal alternative suggestion
Edward Diener
eddielee_no_spam_here at tropicsoft.com
Sat Feb 9 09:08:28 PST 2008
The string literal in D can have a postfix character of 'c', 'w', or 'd'
for specifying the type of the literal. This notation is in the same
spirit as the C++ prefix of L"..." to specify a wide character string.
Such syntax does not play well with templates based on a character type.
I would like to suggest instead the use of a cast(type) expression for
string literals, perhaps something like 'string_cast(type)"some string
literal"' where the type would have to be char, wchar, or dchar. This
says to treat the literal as a particular type and would be a
replacement for "some string literal"c|w|d notation. The reason I think
my suggestion is superior is that one may have a template class or
function in which one of the template parameters is a character type and
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.
More information about the Digitalmars-d
mailing list