需要多高的C++版本?需要什么软件支持?
(之前在其他网站上看到过用表情做宏名的整活代码,据说能运行)
g++ 10.2和clang++ 11.0都支持以Unicode作为标识符。
#include <iostream>
#define 🛑 '\n'
using 🍴 = int;
using 🔷 = double;
struct 🏠
{
🍴 😏 (🍴 🍺, 🍴 🥩)
{
return 🍺 + 🥩;
}
};
int main()
{
🏠 🏨;
std::cout << 🏨.😏(1, 2) << 🛑;
constexpr 🔷 🥧 = 3.1415927;
🔷 r = 5;
🔷 🔵 = 2 * 🥧 * r;
std::cout << 🔵 << 🛑;
}
$ g++ --version
g++ (Debian 10.2.1-6) 10.2.1 20210110
Copyright (C) 2020 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
$ g++ -Wall main.cpp
$ ./a.out
3
31.4159
$ clang++ --version
Debian clang version 11.0.1-2
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
$ clang++ -Wall main.cpp
$ ./a.out
3
31.4159