So many people want to make a template that including everything needed to code faster during rounds. But if your templates are too long, it will take some time to scroll down. So here's a solution (asides from #pragma region): #include __FILE__.
Combine it with #ifdef and other defines, it can move codes to the top section. Here's an example:
#ifndef TYPE_A
#define TYPE_A 1
#include __FILE__
int main()
{
lint a=0;
}
#elif TYPE_A == 1
using lint=long long;
#endif
You can see it just move the lint declartion to the top. But your clangd might give you an error. To bypass this, you need to add a using before the #include. It can be using namespace ..., or using lint = int64_t. But I suggest you to write like this:
#ifndef TYPE_A
#define TYPE_A 1
#include <bits/stdc++.h>
using namespace std;
#include __FILE__
int main()
{
lint a=0;
}
#elif TYPE_A == 1
using lint=long long;
#endif
Now there will be no warnings or errors anymore. Also if you decided to move bits/stdc++.h down below, your clangd will be super slow.
Also you can #include __FILE__ multiple times, just #undef TYPE_A the redefine it. But that will make your template a terrible chaos. Use at your own risk.




