Customizable C++ template generator for competitive programming

Revision en1, by calgagi, 2021-02-18 08:14:36

Hi, I wanted to share a project I've been working on that helps with competitive programming (for me, at least).

The project is here: github.com/calgagi/cp_gen. In short, it's a competitive programming template generator that's highly customizable. It produces files that follow the following format:

#include <bits/stdc++.h>
using namespace std;

// Template name1...
// Template name2...
// Template name3...

// Your main and #defines

Where each "Template nameX" is the contents of lib/nameX.hpp, and "// Your main and #defines" is the contents of user.cpp, which allows you to customize your main and general configuration. You would create this file by running gen filename.cpp -name1 -name2 -name3.

I currently have 4 libraries for myself added, but anyone can create a fork of the repo and add their own libraries/templates/tests (did I mention that you can create automated tests that run on each commit/PR?) extremely easily. For example, just by running gen A.cpp -segtree it can produce a file called A.cpp with the following contents:

/*
 * generated by github.com/calgagi/cp_gen
 * file: A.cpp
 * time: Wed Feb 17 21:08:30 2021
 */

#include <bits/stdc++.h>
using namespace std;
const string CP_GEN_FILE = "A";

// Your lib/segtree.hpp file contents

/* ===== BEGIN USER CODE ===== */

#define ll long long
#define ld long double

void solve() {
    return;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    srand(chrono::steady_clock::now().time_since_epoch().count());
    solve();

    return 0;
}

Anyways, I think it's just a cool project that helps me a ton with competitive programming, and maybe some other people can benefit from it. If you are interested, there's more info in the README :)

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English calgagi 2021-02-18 08:14:36 1929 Initial revision (published)