Better HN
topnewbestaskshowjobs
Log inSign up

jmax01

24 karma · joined Oct 3, 2021 (5y ago) · 12 submissions

Submissions

1.

Building a Fast Lock-Free Queue in Modern C++ from Scratch(jaysmito.dev ↗)

1 points · by jmax01 · 6mo ago · discuss

2.

Building a Hardware Accelerated Live TV Player from Scratch in C with Vulkan(blog.jaysmito.dev ↗)

4 points · by jmax01 · 9mo ago · discuss

3.

Large Collection of Interactive(WASM) Creative Coding Demos C99 OpenGL/WebGL(jaysmito101.github.io ↗)

13 points · by jmax01 · 1y ago · discuss

4.

Implementing Rust-like traits for C++ 20 (with no runtime overhead)

3 points · by jmax01 · 1y ago · 1 comment

comment 1y ago · link · parent

Example Code: struct Shape { void draw(); int area(int x, int y); };

make_trait(Shape, draw, area);

int main() { auto circle = Circle(); auto square = Square(); // NOTE: all of this is strictly checked, so if you are creating // a trait out of a Object, the object MUST implement all the trait functions auto t0 = trait<Shape>::make(&circle); t0.draw();

    auto t1 = trait<Shape>::make(&square);
    t1.draw();

    // Another thing to be kept in mind is trait<T> is just like a View
    // It DOES NOT OWN anything, so you are the one making sure the data
    // pointer is valid
  
    auto array = std::array{t1, t0};
    for (auto& shape : array) {
        std::cout << shape.area(2, 3) << std::endl;
    }    
}

comment 2y ago · link · parent

Yes thats a typo

comment 2y ago · link · parent

Well thats how the current C++ compilers/standard is. There is a limit to what a header/library can do

comment 2y ago · link · parent

I get it, the Rust enum system is such a connivence, but well the secret sauce in the readme is what the "official people" say....

comment 2y ago · link · parent

Hey, I am the author of this, I made this mostly for the purpose of experimenting and playing around and trying out things rather than actually using this for production projects. Making a proper compile time checker is pretty complicated(possibly impossible) without actually getting into the compiler, this just intends emulate that behavior to some extent and have a similar interface. "educational purposes" -> well kinda, I had some free time and had an interesting idea perhaps