LAK132 / defer

Jai-like defer for C++

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Ever wanted to use RAII but didn't want to create a new struct/class every time?

Now you can!

#include <iostream>
#include <defer.hpp>

int main()
{
    // Single function calls can be encapsulated in a DEFER call
    DEFER(printf(", World!"));
    printf("Hello");
}
#include <iostream>
#include <string>
#include <defer.hpp>

int main()
{
    auto *str = new std::string("World!");
    // Blocks can also be encapsulated in a DEFER call
    DEFER({ delete str; printf("\n"); });
    printf("Hello, %s", str->c_str());
}

Dual licensed under MIT and The Unlicense

About

Jai-like defer for C++

License:MIT License


Languages

Language:C++ 100.0%