Mayedl10 / BFIL

Brainfuck intermediate language
Do What The F*ck You Want To Public License
5 stars 0 forks source link

todo: replacing all std::array<something, 2> with structs #8

Closed Mayedl10 closed 9 months ago

Mayedl10 commented 10 months ago

will improve readability and compile time

either just

struct intPair {
    int first;
    int second;
}

or this thing I use in some of my projects

template<typename T1, typename T2>
struct customPair {
    T1 first;
    T2 second;
    customPair(T1 x, T2 y) {
        first = x;
        second = y;
    }
    customPair() {}

    const T1& operator[](int index) const {
        if (index == 0) {
            return first;
        } else if (index == 1) {
            return second;
        } else {
            // Handle out-of-bounds access or throw an exception
            // For simplicity, returning first element if out-of-bounds
            return first;
        }
    }

};