Reputation: 9173
when I was reading codecvt
example in cppref, I noticed this line:
std::string data = reinterpret_cast<const char*>(+u8"z\u00df\u6c34\U0001f34c");
Any idea what is that +
before u8
for? Because I removed it and nothing changed in result.
Upvotes: 1
Views: 216
Reputation: 40836
The +
is "explicitly" performing the array-to-pointer implicit conversion, producing a prvalue const char8_t*
(or const char*
before C++20), instead of an lvalue array.
This is unnecessary since reinterpret_cast<T>
(when T
is not a reference) performs this conversion anyways.
(Possibly it was used to prevent confusion with the similar reinterpret_cast<const char* const&>(u8"...")
, which interprets the bytes of the array as a pointer, which is obviously not what was wanted. But I personally wouldn't worry about this)
Upvotes: 2