Skip to content

Instantly share code, notes, and snippets.

@castano
castano / scope.cpp
Created July 24, 2013 23:49
Various ways to emulate D's scope statements in C++. See http://the-witness.net/news/2012/11/scopeexit-in-c11/
// For C++11 support compile with:
// clang++ -std=c++11 -stdlib=libc++ scope.cpp
#include <stdio.h>
#include <stdlib.h>
template <typename F>
struct ScopeExit {
ScopeExit(F f) : f(f) {}
~ScopeExit() { f(); }
@castano
castano / BSpline.cpp
Created June 15, 2012 19:13
Old b-spline interpolation and approximation code
/*===========================================================================
Title: BSpline.cpp
Module: Pi/MathLib
Author: Ignacio Castaño
Date: 29/05/2000
License: Public Domain
===========================================================================*/
/*----------------------------------------------------------------------------
Doc:
@castano
castano / half_to_float_test.cpp
Created March 21, 2012 18:27
ISPC half to float conversion
#include <intrin.h> // __rdtsc
#include <stdio.h>
typedef unsigned int uint;
typedef unsigned short uint16;
typedef unsigned long long uint64;
// ISPC functions:
extern "C" void half_to_float_test(const uint16 * vin, float * vout, int count);
extern "C" void half_to_float_test_fast(const uint16 * vin, float * vout, int count);