Last active
August 29, 2015 14:06
-
-
Save andyfriesen/f180d5b59fd7f5cb5027 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| struct S { | |
| S(int) {} | |
| S(const S&) = delete; | |
| }; | |
| int main() { | |
| auto a = S { 5 }; // no go | |
| S s {5}; // ok | |
| return 0; | |
| } |
This file contains hidden or 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 <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