Skip to content

Instantly share code, notes, and snippets.

#pragma once
/* This code tries to follow in some instance the following specification for optional type :
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3793.html
* Of course, it's also inspired by the reference TS implementation :
* https://github.com/akrzemi1/Optional
* This implementation do not aim to be the same quality, this is only a study exercise.
* Also based on the cppreference page : http://en.cppreference.com/w/cpp/experimental/optional
* It also does not bother with compatibility, and assumes a C++14 compiler. These omissions
* leads to a somewhat cleaner code in some place.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="potato.js"></script>
</head>
<body onload="init();">
</body>
</html>
@Redchards
Redchards / CTTI.hxx
Created July 26, 2016 13:05
Simple compile time type information.
#ifndef CTTI_HXX
#define CTTI_HXX
#include <ConstString.hxx>
#include <Platform.hxx>
#include <StaticString.hxx>
template<class T>
class CTTI
{
@Redchards
Redchards / ConstString.hxx
Created May 8, 2016 22:27
Simple constexpr assert hack.
#ifndef CONST_STRING_HXX
#define CONST_STRING_HXX
#include <algorithm>
#include <cstddef>
#include <stdexcept>
#include <gsl_assert.h>
#include <ArrayIteratorPolicy.hxx>
@Redchards
Redchards / IteratableEnum.hxx
Created April 20, 2016 20:51
A retought and cleaned up version of the iteratable enum. Considered not that useful.
#ifndef ITERATABLE_ENUM_HXX
#define ITERATABLE_ENUM_HXX
#include <exception>
#include <type_traits>
#include <string>
#include <sstream>
#include <utility>
/* A simple set of functionnality aiming to emulate an interatable enum.
@Redchards
Redchards / Configuration.h
Last active March 23, 2016 11:07
Sample taken from my PeParser project to be reused.
#pragma once
#error This file need modification on linux, be aware of this. Once you made it, you can delete this error.
#include <cstdint>
#include <Windows.h>
#include <winnt.h>
#ifdef DLL_EXPORT
@Redchards
Redchards / graph.html
Created March 13, 2016 22:38
Dirty spline implementation in javascript
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="potato.js"></script>
</head>
<body onload="init();">
</body>
</html>
@Redchards
Redchards / tstImplExo.java
Last active February 25, 2016 22:56
Exercise correction for my project group
package com.chartgen;
import java.awt.Graphics2D;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
//import java.util.Arrays;
import java.util.List;
import javax.imageio.ImageIO;
@Redchards
Redchards / IsLiteral.hxx
Created February 19, 2016 23:00
Simple metafunction to check if an object is of literal type. Used as an example to show how useful the SFINAE is.
#include<type_traits>
// I generally use this metafunction to show how useful the SFINAE is in metaprogramming.
namespace
{
template<class T>
struct constexpr_validator
{
static constexpr T m_{};
@Redchards
Redchards / Bind.cxx
Last active December 5, 2023 13:54
Simple implementation of a function like std::bind.
#include <iostream>
#include <functional>
#include <tuple>
#include <type_traits>
// Actually, a subtle bug may arise when the function is using index_constant as parameter.
// For this reason, a more correct implementation should define a specialized class, hidden in a namespace,
// and forbid the use in other places.
// An easier, more correct, but more verbose way would be to just define two different classes for the argument list
// and the bounded arguments, to avoid the confusion with the index_constant bracket operator overload.