Created
December 2, 2018 23:21
-
-
Save MrQubo/688a322e57876a6b043a4d474cb2043f to your computer and use it in GitHub Desktop.
WTF c++ ?
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 <chrono> | |
#include <ctime> | |
#include <iostream> | |
#include <thread> | |
template <auto f> | |
constexpr auto foo() { | |
return f(); | |
} | |
auto bar() { | |
return std::time(nullptr); | |
} | |
int main() { | |
std::cout << foo<bar>() << std::endl; | |
std::this_thread::sleep_for(std::chrono::seconds(2)); | |
std::cout << foo<bar>() << std::endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment