Skip to content

dujingning/jncpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

- Table of Contents

Ⅰ、jncpp project

A C++ library for everyone to use.

Ⅱ、Description

Header file only for C++ library, simplifying C++ development further.Supports C++11 and later.

Ⅲ、Compile

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 ..

Ⅳ、Features and Usage

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
);

Ⅴ、End

This project was created by DuJingning.

About

A C++ library for everyone to use.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published