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
// This file contains code on how to convert a string to lowercase at compile time. | |
// A large part of the imlementation was taken from http://stackoverflow.com/a/15912824/3161376 which solved the problems that I had in the old implementation. | |
// The string struct will hold our data | |
// The declaration of our string struct that will contain the character array | |
template<char... str> | |
struct string | |
{ | |
// The characters are immediately converted to lowercase when they are put in the array |
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
// Equivalent to std::aligned_storage (taken from https://gist.github.com/calebh/fd00632d9c616d4b0c14e7c2865f3085) | |
namespace poorly | |
{ | |
template<unsigned int Length, unsigned int Alignment> | |
struct aligned_storage | |
{ | |
struct type | |
{ alignas(Alignment) unsigned char data[Length]; }; | |
}; |
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
// Poorly::static_max allows recursively calculating maximum value from size_t parameters/-packs at compile time | |
// Easily editable for any concrete parameters by replacing size_t to your desired type | |
namespace poorly | |
{ | |
// Originally taken from: ( https://gist.github.com/tibordp/6909880 ) | |
// Usage: | |
// template<typename Ts...> | |
// struct MyStruct { const size_t data_size = static_max<sizeof(Ts)...>::value }; | |
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 <utility> | |
#include <typeinfo> | |
#include <type_traits> | |
#include <string> | |
template <size_t arg1, size_t ... others> | |
struct static_max; | |
template <size_t arg> |
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
/* | |
This is free and unencumbered software released into the public domain. | |
Anyone is free to copy, modify, publish, use, compile, sell, or | |
distribute this software, either in source code form or as a compiled | |
binary, for any purpose, commercial or non-commercial, and by any | |
means. | |
In jurisdictions that recognize copyright laws, the author or authors | |
of this software dedicate any and all copyright interest in the |
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
// Taken from Kevlin Henny video https://www.youtube.com/watch?v=YoaZzIZFErI | |
// poorly::midpoint is poor man's std::midpoint that avoids overflow caveat | |
namespace poorly | |
{ | |
struct autoswap_range {}; | |
template<typename T, typename T2 = T> | |
inline constexpr T midpoint(const T& low, const T2& high) noexcept | |
{ |
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
// poorly::sizeof_array is drop-in replacement for plain-c array size deduction | |
// to never have to worry about sizeof(arr)/sizeof(arr[0]) and similar ever again | |
// when needing to pass arrays as ptr and size | |
namespace poorly | |
{ | |
template<typename T, typename SIZE_T = size_t, SIZE_T Size> | |
constexpr SIZE_T sizeof_array(T (&)[Size]) noexcept { return Size; } | |
}; |
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
#pragma once | |
#include <iostream> | |
class Circle | |
{ | |
public: | |
Circle() : m_radius(0) | |
{}; |
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
// poorly::Iterable: poor man's iterator provider that does not take ownership of underlying array | |
// Usage: copy-paste poorly namespace & use MAKE_POORLY_ITERABLE to make plain-c array iterable. | |
// (see examples for more info). | |
#pragma region COPY_PASTE_ITERABLE | |
#include <cstdint> | |
namespace poorly | |
{ | |
template<typename T, size_t SIZE> |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Running Man</title> | |
<meta charset="utf-8" /> | |
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script> | |
<script> | |
ImageFile = "https://gist.githubusercontent.com/IsoPippel/4dc459f44b353fcdf61ad6c42c449764/raw/e9431064ee651524ab916a28e72336abd103cc71/running.png" | |
ImageFileP2 = "https://gist.githubusercontent.com/IsoPippel/4dc459f44b353fcdf61ad6c42c449764/raw/e9431064ee651524ab916a28e72336abd103cc71/running2.png" |