Skip to content

Instantly share code, notes, and snippets.

@Baduit
Baduit / main.cpp
Last active June 30, 2023 20:42
An incomplete but stupid simple compile time string with C++20
#include <iostream>
#include <string_view>
#include <algorithm>
#include <compare>
template <std::size_t ArraySize>
struct CompileTimeString
{
@Baduit
Baduit / Split.hpp
Last active August 6, 2019 07:44
Splitter
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <optional>
#include <initializer_list>
struct Token
{
enum class Type
@Baduit
Baduit / my_span.hpp
Created February 13, 2019 14:54
A little homemade span implementation. I did it to learn how to implement my own iterators.
#include <iterator>
/*
** Warning:
** - no first, last and subspan method
** - no static extend
** - it does not have constexpr support (beacause no static_extent)
*/
template <typename T>
@Baduit
Baduit / scope_guard.cpp
Last active November 27, 2018 16:01
RAII helper 1st thoughts, to complete later
#include <iostream>
#include <functional>
#define SCOPE_GUARD(CbBeginScope, CbEndScope) scope_guard __guard__([&]{CbBeginScope}, [&]{CbEndScope});
#define SCOPE_GUARD_END(CbEndScope) scope_guard __guard_end__([&]{CbEndScope});
#define SCOPE_GUARD_NAMED(name, CbBeginScope, CbEndScope) scope_guard name([&]{CbBeginScope}, [&]{CbEndScope});
#define SCOPE_GUARD_END_NAMED(name, CbEndScope) scope_guard name([&]{CbEndScope});
class scope_guard
@Baduit
Baduit / EzCppTests.hpp
Created August 22, 2018 22:15
A simple cpp header to test easily your code and give you information about the failed tests for small projects.
#pragma once
#include <memory>
#include <vector>
#include <iostream>
#define EXPR_TO_STR(x) #x
#define TEST_BEGIN Test::TestSuiteResult __result__;
#define TEST_END return __result__;