Ad alanları
Türevler
Eylemler

İfadeler

cppreference.com sitesinden
< cpp‎ | language
 
C++
<tr class="t-nv"><td colspan="5"> Dil </td></tr> <tr class="t-nv"><td colspan="5"> Başlık dosyaları (Headers) </td></tr> <tr class="t-nv"><td colspan="5"> Named requirements </td></tr> <tr class="t-nv"><td colspan="5"> Dil desteği kitaplığı </td></tr> <tr class="t-nv"><td colspan="5"> Konseptler kitaplığı(C++20) </td></tr> <tr class="t-nv"><td colspan="5"> Hata tanılama kitaplıği </td></tr> <tr class="t-nv"><td colspan="5"> Yardımcı araçlar kitaplığı </td></tr> <tr class="t-nv"><td colspan="5"> Dizgi (Strings) kitaplığı </td></tr> <tr class="t-nv"><td colspan="5"> Taşıyıcılar (Containers) kitaplığı </td></tr> <tr class="t-nv"><td colspan="5"> Algoritmalar kitaplığı </td></tr> <tr class="t-nv"><td colspan="5"> Yineleyiciler (Iterators) kitaplığı </td></tr> <tr class="t-nv"><td colspan="5"> Numerics library </td></tr> <tr class="t-nv"><td colspan="5"> Giriş/Çıkış kitaplığı </td></tr> <tr class="t-nv"><td colspan="5"> Yerelleştirme kitaplığı </td></tr> <tr class="t-nv"><td colspan="5"> Düzenli ifadeler (RegExp) kitaplığı(C++11) </td></tr> <tr class="t-nv"><td colspan="5"> Atomik işlemler kitaplığı(C++11) </td></tr> <tr class="t-nv"><td colspan="5"> İş parçacığı desteği kitaplığı(C++11) </td></tr> <tr class="t-nv"><td colspan="5"> Dosya sistemi kitaplığı(C++17) </td></tr> <tr class="t-nv"><td colspan="5"> Technical Specifications </td></tr>
 
 
İfadeler
<tr class="t-nv"><td colspan="5"> value categories (lvalue, rvalue, xvalue)</td></tr> <tr class="t-nv"><td colspan="5"> order of evaluation (sequence points)</td></tr> <tr class="t-nv"><td colspan="5"> constant expressions</td></tr> <tr class="t-nv"><td colspan="5"> unevaluated expressions</td></tr> <tr class="t-nv"><td colspan="5"> primary expressions</td></tr> <tr class="t-nv"><td colspan="5"> lambda-expression(C++11)</td></tr> <tr class="t-nv"><td colspan="5"> integer literals</td></tr> <tr class="t-nv"><td colspan="5"> floating-point literals</td></tr> <tr class="t-nv"><td colspan="5"> boolean literals</td></tr> <tr class="t-nv"><td colspan="5"> character literals including escape sequences</td></tr> <tr class="t-nv"><td colspan="5"> string literals</td></tr> <tr class="t-nv"><td colspan="5"> null pointer literal(C++11)</td></tr> <tr class="t-nv"><td colspan="5"> user-defined literal(C++11)</td></tr> <tr class="t-nv"><td colspan="5"> Assignment operators: a=b, a+=b, a-=b, a*=b, a/=b, a%=b, a&=b, a|=b, a^=b, a<<=b, a>>=b</td></tr> <tr class="t-nv"><td colspan="5"> Increment and decrement: ++a, --a, a++, a--</td></tr> <tr class="t-nv"><td colspan="5"> Arithmetic operators: +a, -a, a+b, a-b, a*b, a/b, a%b, ~a, a&b, a|b, a^b, a<<b, a>>b </td></tr> <tr class="t-nv"><td colspan="5"> Logical operators: a||b, a&&b, !a</td></tr> <tr class="t-nv"><td colspan="5"> Comparison operators: a==b, a!=b, a<b, a>b, a<=b, a>=b, a<=>b(C++20)</td></tr> <tr class="t-nv"><td colspan="5"> Member access operators: a[b], *a, &a, a->b, a.b, a->*b, a.*b</td></tr> <tr class="t-nv"><td colspan="5"> Other operators: a(...), a,b, a?b:c </td></tr> <tr class="t-nv"><td colspan="5"> Alternative representations of operators</td></tr> <tr class="t-nv"><td colspan="5"> Precedence and associativity</td></tr> <tr class="t-nv"><td colspan="5"> Fold expression(C++17)</td></tr> <tr class="t-nv"><td colspan="5"> new-expression</td></tr> <tr class="t-nv"><td colspan="5"> delete-expression</td></tr> <tr class="t-nv"><td colspan="5"> throw-expression</td></tr> <tr class="t-nv"><td colspan="5"> alignof</td></tr> <tr class="t-nv"><td colspan="5"> sizeof</td></tr> <tr class="t-nv"><td colspan="5"> sizeof...(C++11)</td></tr> <tr class="t-nv"><td colspan="5"> typeid</td></tr> <tr class="t-nv"><td colspan="5"> noexcept(C++11)</td></tr> <tr class="t-nv"><td colspan="5"> Operator overloading</td></tr> <tr class="t-nv"><td colspan="5"> Implicit conversions</td></tr> <tr class="t-nv"><td colspan="5"> const_cast</td></tr> <tr class="t-nv"><td colspan="5"> static_cast</td></tr> <tr class="t-nv"><td colspan="5"> reinterpret_cast</td></tr> <tr class="t-nv"><td colspan="5"> dynamic_cast</td></tr> <tr class="t-nv"><td colspan="5"> Explicit conversions(T)a, T(a)</td></tr> <tr class="t-nv"><td colspan="5"> User-defined conversion</td></tr>
General
Literals
Operators
Conversions
 

Bir ifade, değerlendirilme belirten bir dizi operatör ve onların işlenenlerini ifade eder.

İfadelerin değerlendirilmesi sonuç (ör. 2+2'nin değerlendirilmesi 4 sonucunu üretir) veya çeşitli yan etkiler üretebilir (ör. std::printf("%d",4)'nin değerlendirilmesi standart çıktı üzerinde '4' karakterini yazdırır).

Konu başlıkları

[düzenle] Genel

  • değer kategorileri (lvalue, rvalue, glvalue, prvalue, xvalue) ifadeleri değerlerine göre sınıflandırır
  • değerlendirilme sırası parametre ve alt-ifadelerin değerlendirilme sırası ara sonuçların elde edildiği sırayı belirtir

[düzenle] Operatörler

Common operators
assignment increment
decrement
arithmetic logical comparison member
access
other

a = b
a = rvalue
a += b
a -= b
a *= b
a /= b
a %= b
a &= b
a |= b
a ^= b
a <<= b
a >>= b

++a
--a
a++
a--

+a
-a
a + b
a - b
a * b
a / b
a % b
~a
a & b
a | b
a ^ b
a << b
a >> b

!a
a && b
a || b

a == b
a != b
a < b
a > b
a <= b
a >= b

a[b]
*a
&a
a->b
a.b
a->*b
a.*b

a(...)
a, b
(type) a
? :

Special operators

static_cast converts one type to another compatible type
dynamic_cast converts virtual base class to derived class
const_cast converts type to compatible type with different cv qualifiers
reinterpret_cast converts type to incompatible type
new allocates memory
delete deallocates memory
sizeof queries the size of a type
sizeof... queries the size of a parameter pack (C++11'den beri)
typeid queries the type information of a type
noexcept checks if an expression can throw an exception (C++11'den beri)
alignof queries alignment requirements of a type (C++11'den beri)

[düzenle] Conversions

[düzenle] Memory allocation

[düzenle] Other


[düzenle] Primary expressions

The operands of any operator may be other expressions or primary expressions (e.g. in 1+2*3, the operands of operator+ are the subexpression 2*3 and the primary expression 1).

Primary expressions are any of the following:

1) Literals (e.g. 2 or "Hello, world")
2) Suitably declared unqualified identifiers (e.g. n or cout)
3) Suitably declared qualified identifiers (e.g. std::string::npos)
5) Fold-expressions (C++17)

Any expression in parentheses is also classified as a primary expression: this guarantees that the parentheses have higher precedence than any operator. Parentheses preserve value, type, and value category.

[düzenle] Literals

Literals are the tokens of a C++ program that represent constant values embedded in the source code.

  • integer literals are decimal, octal, hexadecimal or binary numbers of integer type.
  • character literals are individual characters of type char, char16_t, char32_t, or wchar_t
  • floating-point literals are values of type float, double, or long double
  • string literals are sequences of characters of type const char[], const char16_t[], const char32_t[], or const wchar_t[]
  • boolean literals are values of type bool, that is true and false
  • nullptr is the pointer literal which specifies a null pointer value (C++11'den beri)
  • user-defined literals are constant values of user-specified type (C++11'den beri)

[düzenle] Unevaluated expressions

The operands of the four operators typeid, sizeof, noexcept, and decltype (C++11'den beri) are expressions that are not evaluated (unless they are polymorphic glvalues and are the operands of typeid), since these operators only query the compile-time properties of their operands. Thus, std::size_t n = sizeof(std::cout << 42); does not perform console output.

The unevaluated operands are considered to be full expressions even though they are syntactically operands in a larger expression (for example, this means that sizeof(T()) requires an accessible T::~T)

(C++14'den beri)

The requires-expressions are also unevaluated expressions.

(C++20'den beri)

[düzenle] Discarded-value expressions

A discarded-value expression is an expression that is used for its side-effects only. The value calculated from such expression is discarded. Such expressions include the full expression of any expression statement, the left-hand argument of the built-in comma operator, or the argument of a cast-expression that casts to the type void.

Array-to-pointer and function-to-pointer conversions are never applied to the value calculated by a discarded-value expression. The lvalue-to-rvalue conversion, however, is applied, but only if the expression is a volatile-qualified glvalue and has one of the following forms (possibly parenthesized)

  • id-expression
  • array subscript expression
  • class member access expression
  • indirection
  • pointer-to-member operation
  • conditional expression where both the second and the third operands are one of these expressions,
  • comma expression where the right operand is one of these expressions.
In addition, if the expression is of class type, a volatile copy-constructor is required to initialize the resulting rvalue temporary. (C++17'ye kadar)

If the expression is a prvalue (after any lvalue-to-rvalue conversion that might have taken place), temporary materialization occurs. If the original glvalue is of volatile-qualified class type, a volatile copy-constructor is required to initialize the resulting rvalue temporary.

Compilers may issue warnings when an expression other than cast to void discards a value declared [[nodiscard]]

(C++17'den beri)