Anonymous
Second points to begin+size, in this case theyre same, usually they are different
So, if there are actually 4 elements present in the vector and its size is 8 then the 3rd points to the 8th location and the 2nd pointer points to the 4th location?
Artöm
Yes
Artöm
2nd is begin+size, 3d is begin+capacity
Anonymous
Also, at 7:32, are the pointers automatically deleted? why will we do so?
Artöm
Didn't get that.
You cant (shouldnt) move from an object if somebody else holds a reference to it because one wouldnt know the object was moved-from
Artöm
Also, at 7:32, are the pointers automatically deleted? why will we do so?
Old memory is deleted, pointers are redirected, pointers in moved-from object are zeroed
Artöm
I think he didnt say about deletion because in this example vector was empty
Artöm
Moved from object was an argument of move ctor or move assignment
Artöm
Often (but not always) argument of std::move becomes moved-from
Anonymous
Guys who can help make the code in the matrix write in private messages please
Anonymous
Why private message?
That would not spam in the chat
klimi
Well if it is to topic it doesn't matter? If it is off topic you can ask in offtopic group
Anonymous
Often (but not always) argument of std::move becomes moved-from
At 11:25, does that mean deep copy or shallow copy
Anonymous
BTW In normal terms, when we say copy, what does that mean deep or shallow?
Anonymous
Old memory is deleted, pointers are redirected, pointers in moved-from object are zeroed
old memory of v2 is deleted and pointers of v2 are redirected to that of v1 and pointers of move-from objects revert back to NULL. Right?
Anonymous
old memory of v2 is deleted and pointers of v2 are redirected to that of v1 and pointers of move-from objects revert back to NULL. Right?
Continuing from here to 14:30, the 3 operations that can happen with move-from object are 1.destructor call 2. copy 3. move.
Anonymous
I understand that when we assign this moved-from object with something else then it behaves/becomes like other normal object. But I didn't get about the 3rd operation "move". How can we again make a already moved-from object behave like a moved-from object when its pointers are reverted to NULL?
Ash
https://ide.geeksforgeeks.org/5lkFsGNsSj Someone please tell me why am I not getting the output of the second test case! Input i used is: 2 5 12 1 2 3 7 5 74 665 142 112 54 69 148 45 63 158 38 60 124 142 130 179 117 36 191 43 89 107 41 143 65 49 47 6 91 130 171 151 7 102 194 149 30 24 85 155 157 41 167 177 132 109 145 40 27 124 138 139 119 83 130 142 34 116 40 59 105 131 178 107 74 187 22 146 125 73 71 30 178 174 98 113 Expected output is: 2 4 -1
Artöm
At 11:25, does that mean deep copy or shallow copy
Shallow copy is memcopy, deep copy respects things like dynamic memory holding, that is, if a filed is a dynamic array, with deep copy new memory will be allocated and data copied from old
Anonymous
Hello
klimi
Dark
Hello
Anonymous
I have a vector of vectors and can I apply std::transform in parallel at the outer loop?
Anonymous
there is a way?
Anonymous
std::transform(std::execution::par_unseq, begin, end, newbegin, myop)
Francisco
std::transform(std::execution::par_unseq, begin, end, newbegin, myop)
If your compiler supports the parallel STL, definitely this is the way
Anonymous
begin would be the begin of std::vector<std::vector<double>> for example
Anonymous
yes it supports, but it works with std::vector<std::vector<double>>?
Anonymous
some thing like this: std::vector<std::vector<double>> myvector; std::transform(std::execution::par_unseq, myvector.begin, myvector.end, newvector.begin, myop)
Francisco
yes it supports, but it works with std::vector<std::vector<double>>?
It works with anything, as long as the transformer does what you want
Anonymous
could it work? or do the transformation works only with outer vector? than I need to write this: for(it = begin,it!=end;it++) { std::transform(std::execution::par_unseq, it->begin,it->end, it->begin, myop) }
Anonymous
For vector "pointers are null" is moved-from state
Yes, but how can we perform the move operation when it's pointers are already made NULL. By move I understand that the new object is made to point the memory that has been pointed by moved-from object.
Anonymous
Pointers are copied to new object, then zeroed in old
Yes. But what if the pointers in old object has already been zeroed and is used again as a parameter in std::move()?
Anonymous
v2 = std::move(v1); v3 = std::move(v1);
Francisco
could it work? or do the transformation works only with outer vector? than I need to write this: for(it = begin,it!=end;it++) { std::transform(std::execution::par_unseq, it->begin,it->end, it->begin, myop) }
When you use transform, you apply the passed function to the elements of the range. So in your case, you apply the function to each vector of your vector<vector>. Each call to the function with every vector can return whatever type you want, as long as the destiny range accepts that type
Anonymous
You shouldnt do that
Can you explain the 14:30 where he explains the 3 operations that we can do.
Artöm
Sorry im not home rn
Pavel
Pointers are copied to new object, then zeroed in old
Not sure if they're zeroed. std::move for trivial types are just being replaced by assignment. So if you move a struct without a custom move constructor, then all the trivial member types of the moved object will probably retain their values (not sure if it guaranteed). https://ideone.com/b0lDTX
Artöm
Move construction logic depends on type of course
Marián
Marián
Marián
any ideas why do i get system error here?
Marián
there is almost 0 docs for sndlib
Artöm
Try checking errno
Anonymous
Move construction logic depends on type of course
Is this logic of what happens to the older moved-from object for different types pre-defined that I can look up to?
Artöm
Yes, but it can be unspecified
Artöm
7 https://en.cppreference.com/w/cpp/container/vector/vector
Dima
I am intrigued
Asdew
She just randomly sent me DMs without me asking for them.
gallo
https://pastebin.com/Wis3p6WX good evening can someone tell me what is the problem with this operator? (c ++), as soon as I try to add two objects of this type in the main the error is reported "terminate called after throwing an instance of 'std :: bad_array_new_length' what (): std :: bad_array_new_length" i searched on internet and it should be something related to the length of the array but i don't understand the problem in my code
Samarth
Can someone explain how does the operator overloading works?
Samarth
Just in short
I_Interface
Can someone explain how does the operator overloading works?
It says to compiler how to do an action +/-, etc with your object type (class).
Samarth
I_Interface
I know that.. but i want to know how it functions
https://en.cppreference.com/w/cpp/language/operators
jot.rs
Can someone help me?
Code inside main function would help solve the problem
abdelilah
thank you
Davids
XQ
Davids
hmmmm
Davids
I dont understand
Davids
but its ok
Dima
Lol
Dima
that suspicious name