Skip to content

cybersecurity-dev/awesome-cpp-programming-language

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

67 Commits
 
 
 
 
 
 

Repository files navigation

Awesome C++ Programming Language Awesome

C++11 | C++14 | C++17 | C++20 | C++23 | C++26

YouTube Reddit

GitHub   YouTube   My Awesome Lists

📖 Contents

Containers

Except for the std::vector<bool> partial specialization, the elements are stored contiguously, which means that elements can be accessed not only through iterators, but also using offsets to regular pointers to elements.

std::vector<int> ivec = { 1, 2, 3, 4, 5 };
//lambda expression
auto print = [](const int& n) { std::cout << n << ' '; };
    
std::for_each(ivec.cbegin(), ivec.cend(), print);
std::cout << std::endl;
std::for_each(ivec.crbegin(), ivec.crend(), print);

std::list is a container that supports constant time insertion and removal of elements from anywhere in the container. Fast random access is not supported. It is usually implemented as a doubly-linked list. Compared to std::forward_list this container provides bidirectional iteration capability while being less space efficient.

std::list<int> ilist = { 5, 7, 11, 13 };
for (int n : ilist)
std::cout << n << ", ";
std::cout<<"\n-----------------\n";
    
ilist.push_front(0);
ilist.push_back(-1);
std::for_each(ilist.cbegin(), ilist.cend(), [](auto val) { std::cout << val << ", "; });
std::cout << "\n-----------------\n";
    
//insert with using initializer list
ilist.insert(ilist.cend(), { 4, 3, 2, 1 });
for (auto it = ilist.cbegin(); it != ilist.cend(); ++it) {
    std::cout << *it << ", ";
}

Pointers and References

Smart pointers enable automatic, exception-safe, object lifetime management.

std::unique_ptr is a smart pointer that owns (is responsible for) and manages another object via a pointer and subsequently disposes of that object when the unique_ptr goes out of scope.

{
    unique_ptr<ClassName> uptr(new ClassName);
    uptr -> method_name();
    //....using
} //destructing uptr destroys the ClassName object.

Lambda expression in computer programming, also called an anonymous function, is a defined function not bound to an identifier.

auto make_function(int& iparam)
{
    return [&] { std::cout << iparam << std::endl; };
}

int main()
{
    int ival = 2;
    auto f = make_function(ival); // the use of iparam in f binds directly to ival
    f();
    
    ival = 3;
    f();
    return 0;
}
  • a glvalue ("generalized" lvalue) is an expression whose evaluation determines the identity of an object or function.
  • a prvalue ("pure" rvalue) is an expression whose evaluation.
  • an xvalue (an "eXpiring" value) is a glvalue that denotes an object whose resources can be reused.
  • an lvalue is a glvalue that is not an xvalue.

Some programming languages use the idea of l-values and r-values, deriving from the typical mode of evaluation on the left and right-hand side of an assignment statement. An l-value refers to an object that persists beyond a single expression. An r-value is a temporary value that does not persist beyond the expression that uses it.

void foo();
int main() {
    int ivala; // Expression 'ivala' is lvalue
    int &ivalb{ivala}; // Expression 'ivalb' is lvalue

    // Expression 'foo' is lvalue
    // address may be taken by built-in address-of operator
    void (*ptrfoo)() = &foo;

rvalue

glvalue

a glvalue ("generalized" lvalue) is an expression whose evaluation determines the identity of an object or function.

prvalue

xvalue

Functions

Type Casting

Multithreading

Exception Handling

Idioms

RAII (Resource acquisition is initialization)

PIMPL (Pointer to Implementation)

CRTP (Curiously recurring template pattern)

Language Concepts

auto (Automatic Type Deduction)

ADL (Argument Dependent Lookup)

RTTI (Run-time type information)

SFINAE (Substitution failure is not an error)

Framework and Libraries

Testing and Mocking Framework

  • Catch2 - A modern, C++ native, test framework for unit-tests, TDD and BDD - using C++14, C++17 and later.
  • Google Test - Google Testing and Mocking Framework

Network

  • POCO - The POCO C++ Libraries are powerful cross-platform open-source C++ libraries for building network- and internet-based applications that run on desktop, server, mobile, IoT, and embedded systems.

RPC (Remote Procedure Call)

Performance Analysis and Debugging Tool

  • Orbit - Orbit is a standalone profiler and debugging tool for Windows and Linux. Its main purpose is to help developers understand and visualize the execution flow of a complex application.
  • Tracy Profiler - A real time, nanosecond resolution, remote telemetry, hybrid frame and sampling profiler for games and other applications.

Package Managers

  • vcpkg - vcpkg is a free C/C++ package manager for acquiring and managing libraries.
  • Conan - The open-source C and C++ package manager.

Severals

Standarts

Compiler/Debugger

  • MSVC & GCC & Clang - installation step of MSVC/GCC/Clang compiler in Windows
  • GCC & Clang - installation step of GCC/Clang compiler in Linux
  • OnlineGDB - Online compiler and debugger for C/C++

My Other Awesome Lists

You can access the my other awesome lists here

Contributing

Contributions of any kind welcome, just follow the guidelines!

Contributors

Thanks goes to these contributors!

🔼 Back to top

Contributors