Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define all(x) begin(x),end(x)
- using namespace std;
- struct Data {
- // pjri gnva
- const std::type_info &typeInfo;
- char *bytes = nullptr;
- template<typename T>
- explicit Data(T &x)
- : typeInfo(typeid(x)) {
- bytes = new char[sizeof(x)];
- memcpy(bytes, reinterpret_cast<char *>(&x), sizeof(x));
- }
- template<typename T>
- T *get() {
- if (typeInfo.hash_code() == typeid(T).hash_code()) {
- return reinterpret_cast<T *>(bytes);
- }
- return (T *) nullptr;
- }
- };
- struct MyType {
- } myTypeElement;
- void solve() {
- vector<Data> elements;
- int n = 50;
- string a = "rwqerqwe";
- set<int> kek;
- vector<double> vec;
- vector<Data> data;
- data.emplace_back(n);
- data.emplace_back(a);
- data.emplace_back(kek);
- data.emplace_back(vec);
- data.emplace_back(myTypeElement);
- }
- int main() {
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement