Skip to content

Instantly share code, notes, and snippets.

@rayhamel
Created September 24, 2017 02:50
Show Gist options
  • Save rayhamel/27502fd39f1f550af6e787f89f7f3851 to your computer and use it in GitHub Desktop.
Save rayhamel/27502fd39f1f550af6e787f89f7f3851 to your computer and use it in GitHub Desktop.
Abuse of the C++ language
/* https://wandbox.org/permlink/69aE7gIqBcWonJB0 */
constexpr auto operator""_times(unsigned long long i) noexcept
{
return [i](auto &&f) {
for (auto n{i}; --n; f());
return f();
};
}
#define repeat ([&]{
#define done });
// #include <iostream>
// using namespace std;
// int main()
// {
// int n;
// cin >> n;
// 9_times repeat
// cout << --n << '\n';
// done
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment