Skip to content

Instantly share code, notes, and snippets.

View jharmer95's full-sized avatar
🏢
Working from hybrid

Jackson jharmer95

🏢
Working from hybrid
  • Grosse Pointe, MI
View GitHub Profile
@jharmer95
jharmer95 / composable.hpp
Last active October 5, 2024 04:22
C++ Composables
#include <future>
#include <tuple>
#include <type_traits>
#include <utility>
template <typename F>
class Composable;
template <typename R, bool NoExcept>
class AsyncComposable;
@jharmer95
jharmer95 / better_casts.hpp
Last active February 13, 2023 17:38
Safer, more descriptive casts for C++
#ifndef BETTER_CASTS_HPP
#define BETTER_CASTS_HPP
#include <limits>
#include <stdexcept>
#include <type_traits>
#include <utility>
#if __cplusplus >= 201703L
# define INLINE_CONSTEXPR inline constexpr
@jharmer95
jharmer95 / property.hpp
Last active May 14, 2023 17:06
Class emulating properties for C++
#include <iostream>
#include <memory>
#include <type_traits>
#include <utility>
namespace not_std
{
template<typename T>
constexpr T default_getter(const T& val) noexcept
{
@jharmer95
jharmer95 / rust-to-cpp.md
Last active June 10, 2024 23:25
Translating Rust keywords, concepts, and idioms to C++

Rust to C++

Language Only

Keywords

as

as has a few different contexts in Rust:

@jharmer95
jharmer95 / CMakeLists.txt
Last active June 10, 2021 18:05
Flags for C++ compilers
if(WIN32)
set(TARGET_WINDOWS TRUE)
if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
set(CXX_MSVC TRUE)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set(CXX_MINGW TRUE)
elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CXX_CLANG TRUE)
endif()
elseif(UNIX AND NOT APPLE)
@jharmer95
jharmer95 / .clang-format
Last active July 19, 2022 15:10
Clang Format configuration for C/C++
---
BasedOnStyle: Microsoft
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
AlignConsecutiveAssignments: None
AlignConsecutiveBitFields: true # 11
AlignConsecutiveDeclarations: None
AlignEscapedNewlines: Left
AlignOperands: DontAlign
@jharmer95
jharmer95 / variadic_unpack.cpp
Created November 2, 2020 23:42
Iterating through parameter pack TYPES with a lambda
#include <iostream>
#include <type_traits>
template<typename T>
void printStuff1()
{
if constexpr(std::is_pointer_v<T>)
{
std::cout << "POINTER\n";
}
@jharmer95
jharmer95 / mt_queue.hpp
Created April 23, 2020 18:27
Multithreaded Queue
#pragma once
#include <condition_variable>
#include <mutex>
#include <queue>
template <typename T>
class queue_mt
{
public:
@jharmer95
jharmer95 / MyTypeTraits.hpp
Created July 15, 2019 21:10
Custom C++17 type traits
#pragma once
#include <type_traits>
namespace jjh
{
// Custom because 'custom' is true
class CustomClass1
{
public: