Skip to content

Instantly share code, notes, and snippets.

@toddlipcon
Created February 21, 2018 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toddlipcon/c9a807c6a67037ccd1b63caa93f74c67 to your computer and use it in GitHub Desktop.
Save toddlipcon/c9a807c6a67037ccd1b63caa93f74c67 to your computer and use it in GitHub Desktop.
#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