본문으로 건너뛰기

C++ constexpr

Literal

In computer science, a literal is a notation for representing a fixed value in source code.

Integer literal

https://en.cppreference.com/w/cpp/language/integer_literal

Type: int, ...

  • decimal-literal: 123, 1'234'567U
  • octal-literal: 0127
  • hex-literal: 0x12AF
  • binary-literal: 0b101, 0b1010'0111'1100

Floating point literal

https://en.cppreference.com/w/cpp/language/floating_literal

Type: float, double, ...

1.23f, 1.23e3, 0x1.2, 0x1.2p3

Boolean literal

Type: bool

true, false

Character literal

Type: char, char8_t, char16_t, ...

'a', L'a', u8'a', u'a', U'a', 'asdf', ...

String literal

Type: const char[], const char *, ...

"hello", L"hello", u8"hello", u"hello", U"hello", R"foo(hello)foo", "he" "llo", ...

Pointer literal

Type: std::nullptr_t

nullptr

const

constexpr