Skip to content

Instantly share code, notes, and snippets.

View hnrck's full-sized avatar
💻
I may be slow to respond.

Henrick Deschamps hnrck

💻
I may be slow to respond.
View GitHub Profile
using token_t = std::string;
using tokens_t = std::vector<std::string>;
static inline auto tokenize(const std::string &line, char delimiter) -> tokens_t {
auto tokens = tokens_t{};
auto ss = std::stringstream{line};
auto token = token_t{};
while (std::getline(ss, token, delimiter)) {
if (!token.empty()) {
tokens.push_back(token);
@hnrck
hnrck / 0_my_boolean.md
Created October 11, 2020 12:32
Header only implementation of boolean in modern C++

My boolean

Header only implementation of boolean in modern C++

@hnrck
hnrck / 0_my_unique_pointer.md
Created October 11, 2020 12:28
Header only implementation of the unique pointer in modern C++

My unique pointer

Header only implementation of the unique pointer in modern C++

@hnrck
hnrck / 0_echo_service_tcp_asio.md
Created September 27, 2020 16:44
Header only implementation of echo service in TCP with ASIO in C++

Echo service

Header only implementation of echo service in TCP with ASIO in C++

@hnrck
hnrck / 0_generic_container_class.md
Created September 7, 2020 06:57
Implementation example of a generic container class in C++20

Generic container class

Implementation example of a generic container class in C++20

Summary

Members Descriptions
class Stuff An example class.
class Stuffs The stuffs container class
@hnrck
hnrck / 0_hashtable.md
Created August 11, 2020 20:23
Header only implementation of hashtable in C++20

HashTable

Header only implementation of hashtable in C++20

Summary

Members Descriptions
class HashTable hashtable data structure
class HashTable::Node hashtable node data structure
@hnrck
hnrck / containers_display.cpp
Created July 13, 2020 20:10
Different way to manipulate/display a container
#include <algorithm>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <sstream>
#include <utility>
template<class t_pair>
@hnrck
hnrck / Makefile
Created July 13, 2020 09:02
C++17 thread guard implementation for RAII strategy
CXX?=g++
BIN?=main
EXT?=cpp
LINKS?=pthread
CXXSTD?=c++17
SRCS=$(shell find . -name "*."$(EXT))
DIRS=$(shell find ./* -type d)
OBJS=$(patsubst %.$(EXT),%.o,$(SRCS))
@hnrck
hnrck / accumulate.h
Created July 13, 2020 08:30
C++20 numeric accumulate implementation
#ifndef MY_STD_ACCUMULATE_H
#define MY_STD_ACCUMULATE_H
namespace my_std {
template<class InputIt, class T, class BinaryOperation>
inline auto accumulate(InputIt first, InputIt last, T init, BinaryOperation op) -> T {
for (; first < last; ++first) {
init = op(std::move(init), *first);
}
return init;
@hnrck
hnrck / example.py
Last active June 17, 2020 10:18
Python singleton design pattern
from .singleton import Singleton
class Example(metaclass=Singleton):
"""
Example class.
"""
pass
def main():