A C++ library for everyone to use.
Header file only for C++ library, simplifying C++ development further.Supports C++11 and later.
Ensure CMake is installed
mkdir build; cd build
cmake -DBUILD_EXAMPLES=ON ..
make && make install
Specify installation path
cmake -DCMAKE_INSTALL_PREFIX=$PWD/libs/jncpp ..
The Go programming language has a defer
keyword that allows you to execute code at the end of a function. Similarly, C++ could benefit from such a feature, especially when working with C code. See more defer example.
- Global defer: Runs after the main function.
global_defer
{
std::cout << "defer code 1.0" << std::endl;
}; // semicolon required
- Local defer: Run before the end of scope.
void function() {
defer // Run before the end of scope.
{
std::cout << "defer code 1.0" << std::endl;
}; // semicolon required
{
defer // Run before the end of scope.
{
std::cout << "defer code 0.0" << std::endl;
};
}
}
let std::call_once
more clean, as code:
void function() {
Call_Once (
std::cout << "Call_Once" << std::endl;
}; // semicolon required
);
This project was created by DuJingning.