1..9
prefix)0
prefix)0x
or 0X
prefix)u
or U
and/or l
or L
suffix respectively).
) and/or exponent (e
or E
)f
or F
suffix), or long double (l
or L
suffix)'c'
with \
escape sequencesL
prefix for wchar_t
'many'
type int, implementation defined"string"
with \
escape sequencesL
prefix for const wchar_t[]
(otherwise const char[]
)\0
terminated (but may contain \0
characters)0b
prefix)'
inserted between any digits; i.e. 1'000'000
)0x
or 0X
prefix, requires exponent after p
or P
)'
inserted between any digits; i.e. 1'000'000
)u8
prefix, must be Basic Latin code point)u
prefix, char16_t
)U
prefix, char32_t
)char16_t
and char32_t
are keywords (not typedefs) and name unique typesR"<delimiter>(
<anything>
)<delimiter>"
)\u
arbitrary Unicode 4 digit hex value\U
arbitrary Unicode 8 digit hex valuecout << u8"\U0001F680" << endl;
ostream out(cout.rdbuf());
out << setfill('0') << hex;
for (auto c : u8"\U0001F680") {
out << setw(2) << static_cast<int>(static_cast<uint8_t>(c)) << ' ';
}
cout << u8R"json(
{
"menu": {
"id": 1,
"value": "🚀"
}
}
)json";
_
(others reserved by the standard library).namespace bcc {
struct zstring {
string_view _path;
string_view _value;
};
// Workaround for non-cost string_view::find in libstdc++
constexpr size_t find(const string_view& view, char c) {
size_t result = 0;
for (auto f = begin(view), l = end(view); f != l; ++f, ++result) {
if (*f == c) break;
}
return result;
}
constexpr zstring operator""_z(const char* p, size_t n) {
string_view view(p, n);
auto pos = find(view, '=');
return { view.substr(0, pos), view.substr(pos + 1) };
}
} // namespace bcc
{
using namespace bcc;
constexpr auto zstr = "bcc/greeting=Hello World!"_z;
cout << zstr._path << endl;
cout << zstr._value << endl;
}
namespace bcc {
enum class layer_index: size_t {};
constexpr layer_index operator""_li(unsigned long long int n) {
return static_cast<layer_index>(n);
}
} // namespace bcc
{
using namespace bcc;
constexpr auto id = 4_li;
}
(unsigned long long int)
- integer literal (can be in any integer format)(long double)
- floating point literal(char)
, (wchar_t)
, (char16_t)
, or (char32_t)
- character literals(const char*, size_t)
- string literal (char
can be any character type)(const char*)
- NTBS for source integer or floating point literalnamespace bcc {
void operator""_print(const char* p) {
cout << p << endl;
}
}
{
using namespace bcc;
3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196_print;
}
constexpr
|
A |
|
A |
|
Converts a character array literal to |
|
Creates a string view of a character array literal (C++17) |
u8
encodingchar16_t
or char32_t
as approriateThe app binary listed below was 120.4 MB when you submitted it, but will be 166.7 MB once processed for the App Store. This exceeds the cellular network download size limit and would require your app to be downloaded over Wi-Fi:
App Name: Adobe Photoshop Express
constexpr
where possible