This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <type_traits> | |
#include <functional> | |
template<typename T> | |
using eq_decltype = decltype(std::declval<T>() == std::declval<T>()); | |
template<typename T, typename = std::void_t<>> | |
struct is_equality_comparable : std::false_type {}; | |
template<typename T> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <functional> | |
// This class allows for a function that can return another function with the same signature | |
// ex: a function that takes an int and returns another function that takes an int | |
// Normally this would result in an infinitely recursive type, but by using implicit conversions | |
// we can make the compiler instead only flip-flop between 2 types as needed in a finite manner. | |
template<typename... Args> | |
class StateFuncImpl | |
{ | |
public: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <functional> | |
#include <tuple> | |
#include <string> | |
template<typename T> | |
using remove_cvref_t = std::remove_cv_t<std::remove_reference_t<T>>; | |
// Let's say I have a class like this where I need to store heterogenous data | |
// I don't want to resort to type-erasure |