Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This Ohad Asor guy claims to be a C++ expert with many years experience.
- <naturalog> according to the standard, move() should leave a standard container empty
- Ohad thinks move() moves the removes elements to leave the container empty ?
- when https://wandbox.org/permlink/trRijKZyq6XvZeLR clearly shows it doesn't
- //----------------------------- prog.cc ................................
- // This file is a "Hello, world!" in C++ language by GCC for wandbox.
- #include <iostream>
- #include <vector>
- using namespace std;
- class Data {
- public:
- Data(const std::vector<int>& data): m_data(data) {}
- size_t size() const { return m_data.size(); }
- private:
- std::vector<int> m_data;
- };
- int main() {
- std::vector<int> a = {1, 2, 3, 4, 5};
- std::cout << "a before: " << a.size() << std::endl;
- auto b = Data(std::move(a));
- std::cout << "a after: " << a.size() << std::endl;
- std::cout << "b: " << b.size() << std::endl;
- return 0;
- }
- //----------------------------------------------------------------------------------------
- g++ prog.cc -Wall -Wextra -I/opt/wandbox/boost-1.72.0/gcc-9.2.0/include -std=c++11
- ./a.out
- a before: 5
- a after: 5
- b: 5
- So Ohad decided it was a bug in the C++ compiler that would make the a.size() stay the same! Yes, of course deny deny. HE BLAMED THE C++ COMPILER!
- I have written few as 20,000 lines of C++ over the years and *I* knew better.
- When I quoted https://en.cppreference.com/w/cpp/utility/move he told me i was wrong.. lol (maybe his anger that i wont kiss his ass is what blinds him)
- The only thing worse than his incompetance would be his ego/arrogance [that makes him blame the compiler].
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement