我正在阅读关于“”运算符,发现了一些奇怪的代码片段,我不明白。从字符串转换为const char * + size_t在“”运算符
我不明白从字符串“110011”到const char * s,size_t l的conervsion吗?
我期待这样的:
int operator "" _b (const std::string) { .. }
或 int operator "" _b (const char * s) { .. }
userliteral.cpp
...
int operator "" _b (const char * s, size_t l)
{
int decimal {0};
...//conversion
return decimal;
}
的main.cpp
int bin2dez01 = "110011"_b; //<--- string "110011" to const char *s, size_t l ??????
std::cout << bin2dez01 << "\n";