Created
February 21, 2018 19:56
-
-
Save toddlipcon/c9a807c6a67037ccd1b63caa93f74c67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <vector> | |
#include <iostream> | |
using namespace std; | |
int copied = 0; | |
int moved = 0; | |
struct Foo { | |
Foo() = default; | |
Foo(const Foo& o) { | |
copied++; | |
} | |
Foo(Foo&& o) MAYBE_NOEXCEPT { | |
moved++; | |
} | |
}; | |
int main( int argc, char *argv[]) { | |
vector<Foo> v; | |
for (int i = 0; i < 100; i++) { | |
v.emplace_back(); | |
} | |
cout << "copied=" << copied << endl; | |
cout << "moved=" << moved << endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment