Skip to content

Instantly share code, notes, and snippets.

@MrQubo
Created December 2, 2018 23:21
Show Gist options
  • Save MrQubo/688a322e57876a6b043a4d474cb2043f to your computer and use it in GitHub Desktop.
Save MrQubo/688a322e57876a6b043a4d474cb2043f to your computer and use it in GitHub Desktop.
WTF c++ ?
#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