Once you defined

NS_LITERAL_CSTRING(s) as
static_cast<const nsLiteralCString&>(nsLiteralCString(s))

const char kSomeData[] = {5,5,6,6}; which is no a literal string  can be
passed to the constructor [1].

Non-null terminated data may cause some unexpected behavior.

[1]
https://dxr.mozilla.org/mozilla-central/source/xpcom/string/nsTLiteralString.h#32

2016-08-12 11:16 GMT+08:00 <jww...@mozilla.com>:

> For
> static constexpr auto& kSomeStrLiteral = "hello world";
> NS_LITERAL_CSTRING(kSomeStrLiteral) is not allowed.
>
> However, we can have
> auto s1 = nsLiteralCString("hello world");
> auto s2 = nsLiteralCString(kSomeStrLiteral);
>
> I wonder why didn't we define NS_LITERAL_CSTRING(s) as
> static_cast<const nsLiteralCString&>(nsLiteralCString(s))
> ?
> _______________________________________________
> dev-platform mailing list
> dev-platform@lists.mozilla.org
> https://lists.mozilla.org/listinfo/dev-platform
>
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to