Skip to content

Instantly share code, notes, and snippets.

@andyfriesen
Last active August 29, 2015 14:06
Show Gist options
  • Save andyfriesen/f180d5b59fd7f5cb5027 to your computer and use it in GitHub Desktop.
Save andyfriesen/f180d5b59fd7f5cb5027 to your computer and use it in GitHub Desktop.
struct S {
S(int) {}
S(const S&) = delete;
};
int main() {
auto a = S { 5 }; // no go
S s {5}; // ok
return 0;
}
#include <stdio.h>
struct S {
S() {
printf("Default ctor\n");
}
S(int x) {
printf("int ctor %i\n", x);
}
S(const S&) {
printf("Copy ctor\n");
}
~S() {
printf("dtor\n");
}
};
int main() {
auto a = S { 5 };
S s {5};
return 0;
}
/* prints
int ctor 5
int ctor 5
dtor
dtor
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment