Skip to content

Instantly share code, notes, and snippets.

@mortymacs
Created September 16, 2019 09:30
Show Gist options
  • Save mortymacs/356e35d659cd187124f806a290fec5a9 to your computer and use it in GitHub Desktop.
Save mortymacs/356e35d659cd187124f806a290fec5a9 to your computer and use it in GitHub Desktop.
custom code block in cpp
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <unordered_map>
#include <optional>
#include <functional>
# define eval(a) [&](){a};
#include <iostream>
#include <functional>
struct XWorker {
std::function<void(int, int)> func;
XWorker(std::function<void(int, int)> x): func(x) {
x(10, 12);
}
XWorker() {
}
};
#define Parallel(X) [&](int i, int j){X};
#define Worker XWorker({[&](){X}});
#define RUN(a) auto _ = new a; delete _;
#define TASK [&](int i ,int j)
int main() {
// Worker {
// std::cout << "hello" << std::endl;
// int i;
// };
int capture_value=0;
RUN(
XWorker{
TASK {
std::cout << "i've got these:" << i << "," << j << std::endl;
capture_value = i+j;
}
};
)
std::cout << capture_value << '\n';
// Worker {
// [](int i, int j) {
// return i+j;
// }
// };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment