[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/language/value_category#lvalue [Back]  [Original]

cppreference.com
cppreference.com

cppreference.com

++ ( , , ..) : . , : prvalue, xvalue, lvalue, : rvalue , glvalue.

  • glvalue ( lvalue) , ;
  • prvalue (pure rvalue - rvalue) ,
  • ( prvalue ),
  • (, prvalue ).
, , new, , , . , void ( ). , prvalue , , decltype;
  • xvalue (eXpiring - ) glvalue, , ;
  • lvalue ( , lvalue ) glvalue, xvalue;
  • rvalue ( , rvalue ) prvalue xvalue.

: ++, .


lvalue

lvalue:

  • , , ( C++20) , , std::cin std::endl. rvalue, , , lvalue ( , );
  • , lvalue, std::getline(std::cin, str), std::cout << 1, str1 = str2 ++it;
  • a = b, a += b, a %= b ;
  • ++a --a, ;
  • *p, ;
  • a[n] p[n], , a[n] lvalue ( C++11);
  • a.m, , , m -, a rvalue, m ;
  • p->m, , , m -;
  • a.*mp, , a lvalue, mp ;
  • p->*mp, , mp ;
  • a, b, , b lvalue;
  • a ? b : c, b c (, lvalue , );
  • , ", !";
  • lvalue, static_cast<int&>(x) static_cast<void(&)(int)>(x);
  • , rvalue ;
  • rvalue , static_cast<void (&&)(int)>(x).
( C++11)

:

  • , glvalue ( ).
  • lvalue : &++i[1] &std::endl .
  • lvalue .
  • lvalue lvalue; , .

prvalue

prvalue:

  • ( ), 42, true nullptr;
  • , , str.substr(1, 2), str1 + str2 it++;
  • a++ a--, ;
  • a + b, a % b, a & b, a << b ;
  • a && b, a || b, !a, ;
  • a < b, a == b, a >= b ;
  • &a, ;
  • a.m, , m -[2], a rvalue, m ( C++11);
  • p->m, , m -[2];
  • a.*mp, , mp -[2], a rvalue, mp ( C++11);
  • p->*mp, , mp -[2];
  • a, b, , b rvalue;
  • a ? b : c, b c ( );
  • , static_cast<double>(x), std::string{} (int)42;
  • this;
  • ;
  • , , ( C++20) lvalue;
  • -, [](int x){ return x * x; };
( C++11)
  • requires, requires (T i) { typename T::type; };
  • , std::equality_comparable<int>.
( C++20)

:

  • , rvalue ( ).
  • prvalue : .
  • prvalue, , cv-, , cv- ( C++17). (: prvalue cv- , cv- .)
  • prvalue ( void, , decltype)
  • prvalue .

xvalue

xvalue:

  • , rvalue , std::move(x);
  • a[n], , rvalue;
  • a.m, , a rvalue, m ;
  • a.*mp, , a rvalue, mp ;
  • a ? b : c, b c ( );
  • , rvalue , std::move(x);
  • a[n], subscript, rvalue;
  • rvalue , static_cast<char&&>(x);
( C++11)
  • , , .
( C++17)
( C++23)

:

  • , rvalue ( ).
  • , glvalue ( ).

, rvalue, xvalue rvalue, , glvalue, xvalue , xvalue cv-.

glvalue

glvalue lvalue, xvalue.

:

  • glvalue prvalue lvalue--rvalue, -- --.
  • glvalue : .
  • glvalue , .

rvalue

rvalue prvalue, xvalue.

:

  • rvalue : &int(), &i++[3], &42, &std::move(x) .
  • rvalue .
  • rvalue lvalue, , rvalue, , .
  • rvalue rvalue, , rvalue, , .
  • , rvalue , lvalue , rvalue rvalue ( , , rvalue , ).
( C++11)

-

a.mf p->mf, mf -, a.*pmf p->*pmf, pmf -, prvalue, , - , , (p->*pmf)().

, void, void throw prvalue, . (, , ..) return , void. , throw  ?:.

.

( C++17)

, (, a.m, a lvalue struct A { int m: 3; }) glvalue: , , lvalue . lvalue rvalue glvalue , : .

,

, , lvalue, ,

, rvalue, lvalue ( C++23) rvalue ( C++23) ( , ). .

( C++11)

CPL

CPL , : CPL " ", " ". ( rvalue). ( lvalue). "" "" " " " ".

C

C , , : C " lvalue" ( , ), "lvalue" , , " "[4].

C++98

C++ 2011 C, "rvalue" , lvalue, lvalue , lvalue, rvalue. C, lvalue, lvalue C++.

C++11

C++11, , [5]:

  • : , , , , , ( );
  • : , , , .

C++11 :

  • , lvalue;
  • , xvalue;
  • , prvalue (" rvalue");
  • [6].

, , " glvalue" (glvalue " lvalue"). lvalue, xvalue glvalue.

, , " rvalue". prvalue, xvalue rvalue.

C++17

C++17, , prvalue , , . , , C++11, prvalue .

  1. , i , lvalue.
  2. 2,0 2,1 2,2 2,3 rvalue, -.
  3. , i , lvalue.
  4. " C lvalue, lvalue , , lvalue . C89 lvalue ." -- ANSI C, 6.3.2.1/10.
  5. "" ] , 2010.
  6. prvalue ( ) xvalue T&&, const T&&, " " " " , " " . ; prvalue xvalue const T&.

C++:

CWG 616 C++11 rvalue
prvalue
xvalue
CWG 1059 C++11 prvalue cv-
CWG 1213 C++11 rvalue lvalue xvalue

David Mazires, 2021 - decltype C++

Web Proxy Viewer  |  New URL  |  Original Page