The reason for the question is that I've seen code like this: auto fun(std::vector<Foo>&& v) { std::vector<Bar> w; for (a ...
The reason for the question is that I've seen code like this: auto fun(std::vector<Foo>&& v) { std::vector<Bar> w; for (a ...
I am constructing a shared pointer in a function_1 and giving it as a capture to a lambda. I think this is an issue, could you please confirm if this ...
Why is data in func() repeated? ...
I tried to write some algorithm using recursive function and met this: It doesn't compile, error message: The reason I used "&&" is that ...
The code is: class A { public: void f() { cout << this; } }; int main() { A{}; // prvalue A{}.f(); // Is A{} in here converted to xv ...
I am trying to understand how the move/rvalue assignment operator works. I know that it is largely implementation-specific, but assuming that move ass ...
I have an interesting example to understand lvalue reference, rvalue reference, and std::forward. Maybe it will be a useful example for a deep underst ...
I use C++ https://cppinsights.io/ to see the progress of instantiation, and there's something puzzled between Function&& and Function. I comm ...
I've just read this in C++ Primer : A function parameter that is an rvalue reference to a template type parameter (i.e., T&&) preserves th ...
There are countless explanations as to what the differences between glvalues and prvalues are, but they all pretty much boil down to "everything that ...
I am attempting to move around a pointer by reference (T*&) between some template functions. Under certain conditions this pointer reference may g ...
I have a function that returns a lowercase string: and I expect that function return the same resultat when i will pass "SOME" or const std::string ...
I am new to c++. For this code is_lvalue(fun()) return true. And This I understand, as lvalue reference are afterall lvalues. But for code, is_l ...
Say I have a class object that must be captured by the caller when returning this class's object from a function call. // no_can_rvalue *must* be cap ...
Hello I am a beginner learner in c , today I saw some tricky usage example code in cppreference.com struct tm tm = *localtime(&(time_t){time(NULL ...
After many years of using C++ I realized a quirk in the syntax when using custom classes. Despite being the correct language behavior it allows to cre ...
I read a lot of information about rvalue links, I understood everything, but I met this example: If you pass rvalue to the make_raw_ptr function wi ...
Consider the following code, Entity object is non-movable. I know that std::move(Obj) just cast the Obj to a rvalue reference Obj. And I also know tha ...
Consider this code: There is a friend function in line 14. this function declares an object inside its body. and at the the end returns that object ...
I know it's a bad attempt but why we cannot edit the private member via the getter? I think GetA1() doesn't work because it's using a rvalue, the c ...