Add content to C++ roadmap

This commit is contained in:
Kamran Ahmed committed 2023-06-01 03:18:40 +01:00
1 parent 056256015d
commit cc054bb24b
79 files changed
+4073 -80

No files matched your search

@@ -1 +1,45 @@
# Boost
# Boost C++ Libraries
Boost is a collection of high-quality and widely-used C++ libraries that are designed to help developers write efficient and portable code. They are modular and can be included in your projects as needed. Boost libraries provide various functionalities, including support for parallelism, multithreading, memory management, string manipulation, and advanced data structures.
## Notable Components
Here's a list of some popular Boost libraries:
- **Boost.Asio**: Provides network and low-level I/O services.
- **Boost.Bimap**: A bidirectional map data structure.
- **Boost.Filesystem**: Offers portable file system operations.
- **Boost.Graph**: Implements various graph algorithms and data structures.
- **Boost.Multithreading**: Offers multithreading, synchronization, and thread management tools.
## Usage
1. First, download and install the Boost libraries according to the [documentation](https://www.boost.org/doc/libs/1_76_0/more/getting_started/index.html).
2. After installation, include necessary headers in your C++ code and start using Boost facilities.
Here's an example using `boost::filesystem` (*NOTE: Boost.Filesystem is now part of the C++17 standard library*):
```cpp
#include <iostream>
#include <boost/filesystem.hpp>
int main() {
boost::filesystem::path path("directory_path");
if (boost::filesystem::exists(path)) {
std::cout << "Path: " << path << " exists!" << std::endl;
if (boost::filesystem::is_directory(path)) {
std::cout << "Path: " << path << " is a directory." << std::endl;
} else if (boost::filesystem::is_regular_file(path)) {
std::cout << "Path: " << path << " is a regular file." << std::endl;
}
} else {
std::cout << "Path: " << path << " does not exist!" << std::endl;
}
return 0;
}
```
For a more detailed guide, refer to the [official Boost documentation](https://www.boost.org/doc/libs/).
@@ -1 +1,57 @@
# Open cv
# OpenCV
**OpenCV (Open Source Computer Vision Library)** is an open-source computer vision and machine learning software library. It was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in commercial products. OpenCV contains over 2,500 optimized algorithms for real-time computer vision and is actively used by a large community of programmers, researchers, and industries worldwide.
The library has interfaces for C++, Python, Java, and MATLAB/Octave, and is widely used in various computer vision fields, such as:
- 2D and 3D image processing
- Facial recognition and face detection
- Object detection and recognition
- Machine learning
Here's a simple example using OpenCV in C++ to read and display an image:
**Prerequisite**: Install OpenCV for C++ on your system (e.g., by following the [official installation guide](https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html)).
```cpp
#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
int main(int argc, char** argv) {
if(argc != 2) {
std::cout << "Usage: display_image ImageToLoadAndDisplay" << std::endl;
return -1;
}
cv::Mat image;
image = cv::imread(argv[1], cv::IMREAD_COLOR);
if(!image.data) {
std::cout << "Could not open or find the image" << std::endl;
return -1;
}
cv::namedWindow("Display window", cv::WINDOW_AUTOSIZE);
cv::imshow("Display window", image);
cv::waitKey(0);
return 0;
}
```
This example reads an image from the given input path (`argv[1]`) and displays it in a window. The `cv::imread()` function is used to read the image, and the `cv::imshow()` function displays it in the created window.
Remember to compile the code, linking the necessary libraries:
```
g++ -o display_image display_image.cpp `pkg-config --cflags --libs opencv4`
```
And run the executable with an image path as an argument:
```
./display_image path/to/image.jpg
```
For more advanced examples and detailed documentation on how to use OpenCV, please visit the [official OpenCV documentation](https://docs.opencv.org/master/).
@@ -1 +1,71 @@
# Poco
# Poco
Poco (also known as POCO C++ Libraries) is a collection of open-source class libraries, which simplifies the creation of network-centric, portable, and maintainable software in C++.
### Overview
Poco library provides functionality for various areas, such as:
- Networking: HTTP, FTP, SMTP, POP3, and other internet protocols
- File handling: FileSystem, Path, File, and Directory classes
- XML processing: XML parsing and DOM manipulation
- Logging: Loggers, levels, channels, patterns, etc.
- Data manipulation: Stream, ByteBuffer, Buffer, etc.
- Multithreading and synchronization: Threads, Mutex, Event, and Condition
### Code Example
Here's an example demonstrating an HTTP client using the Poco library:
```cpp
#include <Poco/Net/HTTPClientSession.h>
#include <Poco/Net/HTTPRequest.h>
#include <Poco/Net/HTTPResponse.h>
#include <Poco/Net/HTTPMessage.h>
#include <Poco/StreamCopier.h>
#include <iostream>
#include <string>
using namespace Poco::Net;
using namespace Poco;
using namespace std;
int main()
{
try
{
// Prepare the request
URI uri("http://example.com");
HTTPClientSession session(uri.getHost(), uri.getPort());
HTTPRequest request(HTTPRequest::HTTP_GET, uri.getPath(), HTTPMessage::HTTP_1_1);
request.setContentType("application/json");
session.sendRequest(request);
// Process the response
HTTPResponse response;
istream& responseStream = session.receiveResponse(response);
if (response.getStatus() == HTTPResponse::HTTP_OK)
{
// Successful
StreamCopier::copyToString(responseStream, responseBody);
cout << "Response: " << responseBody << endl;
}
else
{
// Error
cout << "Error: " << response.getStatus() << " " << response.getReason() << endl;
}
}
catch(const Exception& e)
{
cerr << "Error: " << e.displayText() << endl;
return -1;
}
return 0;
}
```
In the above example, Poco is used to send an HTTP GET request and process the response. It manages tasks like connecting to the server, handling exceptions, and managing HTTP headers.
@@ -1 +1,53 @@
# Tensorflow
# TensorFlow
TensorFlow is an open-source machine learning library developed by researchers and engineers from the Google Brain team. It is designed for building, training, and deploying deep learning models. TensorFlow provides a set of tools for ML, deep learning, and numerical computation using data flow graphs. TensorFlow can process computations on GPUs and TPUs, which speed up training time and ensures efficient model deployment.
## Installation
You can install TensorFlow using the Python package manager pip:
```bash
pip install tensorflow
```
## Basic usage
Here's a simple example of how to create and train a neural network with TensorFlow:
```python
import tensorflow as tf
from tensorflow import keras
# Load dataset
mnist = keras.datasets.mnist
(train_images, train_labels), (test_images, test_labels) = mnist.load_data()
# Preprocess data
train_images = train_images / 255.0
test_images = test_images / 255.0
# Define model
model = keras.Sequential([
keras.layers.Flatten(input_shape=(28, 28)),
keras.layers.Dense(128, activation='relu'),
keras.layers.Dense(10, activation='softmax')
])
# Compile model
model.compile(optimizer='adam',
loss='sparse_categorical_crossentropy',
metrics=['accuracy'])
# Train model
model.fit(train_images, train_labels, epochs=5)
# Evaluate model
test_loss, test_acc = model.evaluate(test_images, test_labels, verbose=2)
print('\nTest accuracy:', test_acc)
```
This code loads the MNIST dataset, preprocesses the data, creates a simple neural network, compiles it, trains it, and evaluates its performance on the test set.
For more advanced usage, TensorFlow offers several APIs like `tf.data`, `tf.keras`, and `tf.estimator` that enable flexible and efficient data input pipelines, composing and training complex neural network architectures, and managing large-scale distributed training.
You can visit TensorFlow's official website (https://www.tensorflow.org/) and their GitHub repository (https://github.com/tensorflow/tensorflow) for more information, tutorials, and resources.
@@ -1 +1,59 @@
# Spdlog
# Spdlog
`spdlog` is a fast, header-only, C++ logging library. It provides a simple and efficient way to add diagnostic logging to your C++ application.
### Features:
- Header-only, no need to build or link a library
- Highly configurable, including support for custom log sinks (e.g. writing to a file or a database)
- Asynchronous and synchronous logging modes
- Preprocessor-based format string checks to catch bugs at compile-time
- Easy to extend with custom formatters, sinks, and levels
### Usage example:
Include the `spdlog` header, create a logger object, and use it to log messages:
```cpp
#include "spdlog/spdlog.h"
int main() {
// Create a logger with the name "example_logger"
auto logger = spdlog::stdout_color_mt("example_logger");
// Log messages with various severity levels
logger->info("Welcome to spdlog!");
logger->warn("Warning message");
logger->error("Error message");
return 0;
}
```
### Custom sink example:
Here's an example of creating a logger with a custom sink that writes to a text file:
```cpp
#include "spdlog/spdlog.h"
#include "spdlog/sinks/basic_file_sink.h"
int main() {
// Create a file sink to write logs to "logs.txt"
auto file_sink = std::make_shared<spdlog::sinks::basic_file_sink_mt>("logs.txt");
// Create a logger with the file sink and the name "example_logger"
auto logger = std::make_shared<spdlog::logger>("example_logger", file_sink);
// Register the logger
spdlog::register_logger(logger);
// Log messages
logger->info("Welcome to spdlog!");
logger->warn("Warning message");
logger->error("Error message");
return 0;
}
```
For more examples and detailed documentation, visit the [spdlog GitHub repository](https://github.com/gabime/spdlog).
@@ -1 +1,69 @@
# Fmt
# fmt
`fmt` is a modern C++ formatting library that provides an easy and efficient way to format text and print it to various outputs. The library offers a high level of compatibility with C++ standards, making it suitable for various applications and platforms. `fmt` emphasizes simplicity, extensibility, and type safety.
## Features
- Supports positional and named arguments for better readability in complex formatting tasks
- Supports format string syntax similar to Python's `str.format()`
- Provides compile-time format string checks for type safety
- Extensive documentation and user-friendly API
## Example Usage
Here are some examples of how to use the `fmt` library:
### Basic Usage
```cpp
#include <fmt/core.h>
int main() {
fmt::print("Hello, world!\n");
return 0;
}
```
### Formatting with Positional Arguments
```cpp
#include <fmt/core.h>
int main() {
fmt::print("The answer is {}.\n", 42);
fmt::print("{1}, {0}!\n", "world", "Hello");
return 0;
}
```
### Formatting with Named Arguments
```cpp
#include <fmt/core.h>
int main() {
fmt::print("Hello, {name}!\n", fmt::arg("name", "world"));
return 0;
}
```
### Using Format String Syntax
```cpp
#include <fmt/core.h>
int main() {
fmt::print("{:<30}", "left-aligned");
fmt::print("{:>30}", "right-aligned");
fmt::print("{:^30}", "center-aligned");
fmt::print("{:*^30}", "center-aligned");
fmt::print("int: {0:d}; hex: {0:x}; oct: {0:o}; bin: {0:b}", 42);
fmt::print("{:.2f}", 3.1415926);
fmt::print("{:010.2f}", 3.1415926);
return 0;
}
```
For more information, you can refer to the official [fmt documentation](https://fmt.dev/latest/index.html).