Literal operator template: why not string?

后端 未结 1 1564
逝去的感伤
逝去的感伤 2021-02-15 05:30

Once again, while replying to another question, I forgot (my fault) that literal operator templates are picked up from the set of declarations only when integer or floating lite

相关标签:
1条回答
  • 2021-02-15 05:48

    There where complications involving character sets and encoding and other such mess. What happens if the character set encoding differs between runtime and compile time, what happens if there are multiple ways to encode the same character, does the string being utf-8 encoded vs a different encoding do anything? Do you translate to the runtime character set, or not?

    Maybe there are easy answers; but there was enough complication that the proposers went "ok, we'll cut this" and the literals got into the standard.

    The characters permitted for floating point and integral literals where limited, and did not have this problem.

    But you linked to a document that linked to N2750, and which directly stated:

    there may be demand for a "raw" form of string literal, in which

    "Hello, " L"Worl\u0044!"
    

    is distinguishable from

    L"Hello, World!"
    

    but this interacted badly with phases of translation, and no compelling use cases for this feature were known.

    0 讨论(0)
提交回复
热议问题