Skip to content

Instantly share code, notes, and snippets.

View Atrix256's full-sized avatar

Alan Wolfe Atrix256

View GitHub Profile
@oktal
oktal / compile-time-crc32.cc
Created May 14, 2013 02:00
Compile-time C++ CRC32
constexpr unsigned int crc32_table[] = {
0, 0x77073096, 0xEE0E612C, 0x990951BA,
0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,
0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,
0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,
0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,
0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,
0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,
0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,
0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,
@twoscomplement
twoscomplement / gist:80c164be5cad7f51939e512f0142a5eb
Last active April 10, 2017 07:50
CRC tables, generated at compile time using C++11 constexpr, C++14 utility library, variadic template, initializer list
// CRC tables, generated at compile time using C++11 constexpr, C++14 utility library, variadic template, initializer list
// Compiled and tested using msvc 2015, gcc 6.2, and clang 3.9.0.
// clang requires -std=c++14 -ftemplate-depth=512
#include <stdint.h>
#include <utility>
template<typename T, T Poly>
struct CrcTable {
static constexpr T Generate(T v, int r = 8) {