A

@Adarsh1999

Structured binding

C++
3 years ago
Structured binding is a feature introduced in C++17 that allows for more concise and readable code when working with tuple-like types. It allows you to easily unpack the elements of a tuple, or the members of a struct, into individual variables.

constexpr lambda

C++
3 years ago
/*constexpr lambda is a C++ feature that allows you to define a lambda function that can be evaluated at compile-time, if the arguments passed to it are also known at compile-time. This is useful when you need to do some computation at compile-time

Nested Namespace

C++
3 years ago
A nested namespace is a namespace that is defined within another namespace. It allows for organization and grouping of related namespaces. #include <iostream> namespace A { int x = 1; namespace B { int y = 2;

Inline variable

C++
3 years ago
In C++17 and later, the "inline" keyword can also be used for variables, in addition to functions. This allows for variables to be defined in header files and have their definition "inlined" into each translation unit that includes the header. Thi

advanced if statement

C++
3 years ago
C++17 and C++20 introduced several new features and improvements to the C++ language, including new forms of the if statement. One new form of the if statement in C++17 is the if constexpr statement. This allows the compiler to perform compile

future and wait

C++
3 years ago
/*std::future is a C++11 class that represents a value or an exception that will be available in the future. It can be used to retrieve the result of a function executed in a separate thread of execution. One way to wait for the result of a std

Jthread most recent one

C++
3 years ago
Task-based concurrency is a programming paradigm that allows developers to write concurrent code by specifying tasks (i.e., units of work) that can be executed in parallel, rather than explicitly managing threads and synchronization mechanisms.

std::async

C++
3 years ago
/* std::async is a function that is part of the C++11 Standard Template Library (STL) and allows for the creation of asynchronous operations. Asynchronous operations allow a program to perform multiple tasks simultaneously without waiting for on

Thread synchronization

C++
3 years ago
/* Thread synchronization is a mechanism that ensures that two or more concurrent threads do not simultaneously execute certain program segments, called "critical sections". This can be important to prevent race conditions, where the outcome of th

thread arguments

C++
3 years ago
#include <iostream> #include <thread> void print_message(std::string message, int count) { for (int i = 0; i < count; i++) { std::cout << message << std::endl; std::this_thread::sleep_for(std::chrono::milliseconds(1000));

Thread basics

C++
3 years ago
/*In C++, a thread is a separate execution flow that can run concurrently with other threads. Threads are useful for parallelizing work, such as performing multiple tasks simultaneously or running a time-consuming task in the background while the ma

Emplace with vector

C++
3 years ago
The emplace() function is a member function of the std::vector container in C++, which allows you to construct a new element in-place, without the need to copy or move an existing object. The function takes one or more arguments, depending on the

std algorithm

C++
3 years ago
Here is an example of a C++ program that uses multiple STL algorithms to perform various operations on a vector: Copy code #include <iostream> #include <vector> #include <algorithm> int main() {

std::hash

C++
3 years ago
std::hash is a template class in the C++ Standard Template Library (STL) that provides a default hash function for certain types. It is used to define the hash function for unordered containers, such as unordered_map, unordered_set, and unordere

Unordered container

C++
3 years ago
An unordered container is a type of container in which elements are not stored in a specific order, unlike ordered containers such as vector or list. C++ provides several unordered containers, including unordered_map, unordered_set, and unordered_m

Associative containers

C++
3 years ago
#include <iostream> #include <set> #include <functional> #include <map> #include <string> void Set() { std::multiset<int, std::greater<int>> s{ 8,2,0,9,5 }; //No push_back, only insert as elements are ordered automatically s.insert(1);

map and multimap

C++
3 years ago
In C++, the map and multimap container classes are used to store key-value pairs, where the keys are unique in a map and can be non-unique in a multimap. Both classes are implemented as balanced binary search trees and provide logarithmic time

std set multiset

C++
3 years ago
A std::set is a container class in the C++ Standard Template Library (STL) that stores a collection of unique elements in a sorted order. It is implemented as a balanced binary search tree, which allows for efficient insertion, removal, and lookup o

std list

C++
3 years ago
A std::list is a container class in the C++ Standard Template Library (STL) that stores a doubly-linked list of elements. Like a std::vector and std::deque, std::list provides automatic memory management and dynamic resizing, but unlike these co

std deque

C++
3 years ago
A std::deque (short for "double-ended queue") is a container class in the C++ Standard Template Library (STL) that stores a dynamically-sized array of elements. Like a std::vector, a std::deque provides automatic memory management and dynamic res