Skip to content
Sign upLog in
← Back to Community

C++ unknown type?

Profile icon
xxpertHacker

I'm trying to figure out what type u'0' and u"0" are, but std::char8_t doesn't exist, so is it an un-named type?

Ahh, these don't even compare!
https://repl.it/@xxpertHacker/missingno-1#main.cpp

Voters
Profile icon
planckelucas34
Profile icon
xxpertHacker
Comments
hotnewtop
Profile icon
xxpertHacker

@DynamicSquid
@CSharpIsGud

I need help, do either of you have any time to check out this nonsense?

Profile icon
CSharpIsGud

@xxpertHacker
You mean like this?

char8_t c = 0; std::cout << (typeid(u'0') == typeid(c)) << "\n"; // 1

char8_t isn't in std

Profile icon
xxpertHacker

@CSharpIsGud
Ha, do you have a C++ 20 compiler or what?

Repl uses a C++17 compiler.

Profile icon
CSharpIsGud

@xxpertHacker
I used repl

Profile icon
DynamicSquid

@CSharpIsGud
Wait, I thought char8_t was C++20?

Profile icon
xxpertHacker

@DynamicSquid
Yeah, same, afaict, it's a C++20 keyword. I sure can't get it to run on Repl.

@CSharpIsGud
, can you link the Repl?

And regardless of char8_t or whatever, why does my second Repl's assertions fail? That makes no sense, whatsoever; I only used relative type deduction.

Profile icon
xxpertHacker

@DynamicSquid
@CSharpIsGud

Oh shoot, I do think it is char8_t, even if it's not exposed as the keyword, since I got a compiler errors mentioning it by name:

././base64.hpp:40:15: error: initializing 'char8_t' array with plain string literal constexpr u8 b64[] = ^ ././base64.hpp:41:3: note: add 'u8' prefix to form a 'char8_t' string literal "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ^ u8

with u8 as a type alias of decltype(u8'\0').

Now I'm just lost as to what *u8"" is, if it's not char8_t const&.

Profile icon
DynamicSquid

@xxpertHacker
I'm so lost. This hurts my head.

Profile icon
CSharpIsGud

@xxpertHacker
I found this http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1423r0.html

Profile icon
xxpertHacker

@CSharpIsGud
That just confirms what I said, that char8_t is a C++20 thing?

Profile icon
Baconman321

wait wut u can declare operators? kewl!

Oh, wait... I read it wrong :/