Created
March 10, 2025 09:50
-
-
Save flomnes/5b62b714e5f90ce625954a32f5e3d310 to your computer and use it in GitHub Desktop.
Order execution
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 <iostream> | |
#include <string> | |
#include <string_view> | |
#include <utility> | |
template<class T> | |
T&& log(T&& in, std::string_view msg) | |
{ | |
std::cout << msg << std::endl; | |
return std::move(in); | |
} | |
int f(std::string&& a, std::string&& b) | |
{ | |
auto q = std::move(a); | |
auto r = std::move(b); | |
return q.size() + r.size(); | |
} | |
int main() | |
{ | |
std::string m("VP"); | |
std::cout << f(log(std::move(m), "first"), log(std::move(m), "second")) << std::endl; | |
/* Possible output | |
second | |
first | |
2 | |
*/ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment