Last active
June 21, 2016 19:55
-
-
Save terrelln/5d15b7f6018fabd25c172e9a7b8d2c83 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 <iostream> | |
struct skeleton { | |
skeleton() { std::cout << "skeleton()" << std::endl; } | |
skeleton(const skeleton&) { std::cout << "skeleton(const skeleton&)" << std::endl; } | |
skeleton(skeleton&) { std::cout << "skeleton(skeleton&)" << std::endl; } | |
skeleton(const skeleton&&) { std::cout << "skeleton(const skeleton&&)" << std::endl; } | |
skeleton(skeleton&&) { std::cout << "skeleton(skeleton&&)" << std::endl; } | |
skeleton& operator=(const skeleton&) { | |
std::cout << "skeleton& operator=(const skeleton&)" << std::endl; | |
return *this; | |
} | |
skeleton& operator=(skeleton&) { | |
std::cout << "skeleton& operator=(skeleton&)" << std::endl; | |
return *this; | |
} | |
skeleton& operator=(const skeleton&&) { | |
std::cout << "skeleton& operator=(const skeleton&&)" << std::endl; | |
return *this; | |
} | |
skeleton& operator=(skeleton&&) { | |
std::cout << "skeleton& operator=(skeleton&&)" << std::endl; | |
return *this; | |
} | |
void foo() const& { std::cout << "void foo() const&" << std::endl; } | |
void foo() & { std::cout << "void foo() &" << std::endl; } | |
void foo() const&& { std::cout << "void foo() const&&" << std::endl; } | |
void foo() && { std::cout << "void foo() &&" << std::endl; } | |
static void bar(const skeleton&) { std::cout << "static void bar(const skeleton&)" << std::endl; } | |
static void bar(skeleton&) { std::cout << "static void bar(skeleton&)" << std::endl; } | |
static void bar(const skeleton&&) { std::cout << "static void bar(const skeleton&&)" << std::endl; } | |
static void bar(skeleton&&) { std::cout << "static void bar(skeleton&&)" << std::endl; } | |
~skeleton() { std::cout << "~skeleton()" << std::endl; } | |
}; | |
void fn(skeleton x) { x.foo(); } | |
void gn(skeleton &&x) { | |
auto y = std::move(x); | |
y.foo(); | |
} | |
int main() { | |
fn(skeleton{}); | |
gn(skeleton{}); | |
skeleton x; | |
fn(std::move(x)); | |
gn(std::move(x)); | |
} | |
/** OUTPUT: | |
skeleton() | |
void foo() & | |
~skeleton() | |
skeleton() | |
skeleton(skeleton&&) | |
void foo() & | |
~skeleton() | |
~skeleton() | |
skeleton() | |
skeleton(skeleton&&) | |
void foo() & | |
~skeleton() | |
skeleton(skeleton&&) | |
void foo() & | |
~skeleton() | |
~skeleton() | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment