Last active
June 26, 2018 02:46
-
-
Save shininglion/53a8b5fdbc1272a18cfec79cf18a4412 to your computer and use it in GitHub Desktop.
prvalue sucks
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
/* | |
* ===================================================================================== | |
* | |
* Filename: prvalue.cpp | |
* | |
* Description: test prvalue | |
* | |
* Version: 1.0 | |
* Created: 2018/06/26 (yyyy/mm/dd) | |
* Revision: none | |
* Compiler: g++ (C++17) | |
* | |
* Author: lionking | |
* Organization: None | |
* Source: https://www.youtube.com/watch?v=uYDt1gCDxhM&list=PLHTh1InhhwT6bwIpRk0ZbCA0N2p1taxd6&t=0s&index=117 | |
* | |
* ===================================================================================== | |
*/ | |
#include <iostream> | |
void bloop(int&&) { std::cout << "int move!\n"; } | |
void bloop(int const&) { std::cout << "int copy!\n"; } | |
int const intbar() { return {}; } | |
struct foo {}; | |
void bloop(foo&&) { std::cout << "foo move!\n"; } | |
void bloop(foo const&) { std::cout << "foo copy!\n"; } | |
foo const foobar() { return {}; } | |
int main() | |
{ | |
bloop(intbar()); // print "int move!" | |
bloop(foobar()); // print "foo copy!" | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment