Created
April 23, 2022 10:30
-
-
Save Hexlord/73a13ec5a7f5c8f41625c22405b4a895 to your computer and use it in GitHub Desktop.
This file contains 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 <fstream> | |
#include <iostream> | |
#include <string> | |
#include <vector> | |
using namespace std; | |
int main() { | |
ofstream Out("Result.h"); | |
Out << "template<typename... Ts>\n" | |
<< "struct TTuple;\n\n"; | |
vector<string> Words = {"First", "Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh", "Eighth", "Ninth", "Tenth", "Eleventh", "Twelfth", "Thirteenth", "Fourteenth", "Fifteenth", "Sixteenth"}; | |
auto WordCount = Words.size(); | |
for (size_t Count = 1; Count <= WordCount; ++Count) { | |
Out << "template<"; | |
for(size_t ArgIndex = 0; ArgIndex < Count; ++ArgIndex) { | |
Out << "typename T" << (ArgIndex + 1); | |
if(ArgIndex + 1 < Count) { | |
Out << ", "; | |
} | |
} | |
Out << ">\n"; | |
Out << "struct TTuple<"; | |
for(size_t ArgIndex = 0; ArgIndex < Count; ++ArgIndex) { | |
Out << "T" << (ArgIndex + 1); | |
if(ArgIndex + 1 < Count) { | |
Out << ", "; | |
} | |
} | |
Out << "> {\n"; | |
for(size_t ArgIndex = 0; ArgIndex < Count; ++ArgIndex) { | |
Out << "T" << (ArgIndex + 1) << " " << Words[ArgIndex] << ";\n"; | |
} | |
Out << "\n"; | |
Out << "template<uint32 Index>\n"; | |
Out << "const auto &Get() const {"; | |
for(size_t ArgIndex = 0; ArgIndex < Count; ++ArgIndex) { | |
Out << "if constexpr (Index == " << ArgIndex << ") {\n"; | |
Out << "return " << Words[ArgIndex] << ";\n"; | |
Out << "}\n"; | |
} | |
Out << "Prevent();\n"; | |
Out << "}\n\n"; | |
Out << "template<uint32 Index>\n"; | |
Out << "auto &Get() {"; | |
for(size_t ArgIndex = 0; ArgIndex < Count; ++ArgIndex) { | |
Out << "if constexpr (Index == " << ArgIndex << ") {\n"; | |
Out << "return " << Words[ArgIndex] << ";\n"; | |
Out << "}\n"; | |
} | |
Out << "Prevent();\n"; | |
Out << "}\n"; | |
Out << "};\n\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment