Skip to content

Instantly share code, notes, and snippets.

💭
I'm working on the thing that uses QueueWorld

Ross Bencina RossBencina

💭
I'm working on the thing that uses QueueWorld
Block or report user

Report or block RossBencina

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@RossBencina
RossBencina / illegal_explicit_specialization.cpp
Created Feb 20, 2017
You can't use explicit function specialization at class scope
View illegal_explicit_specialization.cpp
class Foo{
template<typename X>
void foo()
{
}
template<>
void foo<int>() // error: explicit specialization of 'foo' in class scope
{
@RossBencina
RossBencina / tag_dispatch_flags
Last active Dec 5, 2016
Using tag-dispatch to implement or-combinable flags. Code for my SO question: http://stackoverflow.com/questions/40977757
View tag_dispatch_flags
#include <iostream>
// **Current Solution: Part 1 - send() function**
// This is the easy part.
// First, a type-level enum helper
template<typename EnumClass, EnumClass X>
struct EnumValue {
View bugs.cpp
// These are reduced test cases derived from a work-in-progress (non-production) code base.
// Can you spot the bugs that PVS-Studio found?
#include <atomic>
#include "catch.hpp"
///////////////////////////////////////////////////////////////////////////////
// Bug #1
View jmc_polynomial.py
# Symbolic integration of [(1 - x^a)^b * e^iwx] dx from -1 to 1
# see discussion on music-dsp mailing list
# "Re: [music-dsp] a family of simple polynomial windows and waveforms"
from math import factorial
from copy import deepcopy
import string
# binomial coefficient nCk
def binomial(n, k):
@RossBencina
RossBencina / SH1.py
Last active Nov 5, 2015
Compute spectrum of sample-and-hold noise
View SH1.py
# see https://lists.columbia.edu/pipermail/music-dsp/2015-November/000424.html
# psd derivation due to Ethan Duni
import numpy as np
from numpy.fft import fft, fftfreq
import matplotlib.pyplot as plt
N = 16384*2*2*2*2*2 # FFT size
y = (np.random.random(N) * 2) - 1 # ~U(-1,1)
r = np.random.random(N) # ~U(0,1)
@RossBencina
RossBencina / inherit-types-from-template-base-class.cpp
Created Aug 31, 2015
Experiment: Inheriting Types From Template Base Class
View inherit-types-from-template-base-class.cpp
/// Inheriting Types From Template Base Class
/// =========================================
///
/// I put together this comparison of various methods of looking up types in
/// a base class template after noticing that my code would compile correctly
/// in MSVC but break in clang and gcc.
///
/// Having reviewed the various cases, my conclusion is that MSVC is very
/// permissive in looking up names in base class templates. It doesn't
/// implement the correct C++ dependent name lookup rules.
View MyAsyncMethod.cpp
// Template-based async method continuation idea by Ross Bencina <rossb@audiomulch.com> May 2014.
// see: https://groups.google.com/forum/#!topic/comp.lang.c++.moderated/ryhWI6cX3Ko
#include <iostream>
#include <list>
typedef void (*async_callback_fn_t)(void*);
struct PendingSimulatedTaskCallback{
async_callback_fn_t simulatedAsyncCallbackFn_;
@RossBencina
RossBencina / MyCoroutine.cpp
Last active Aug 29, 2015
C++ Coroutine Using Template
View MyCoroutine.cpp
// Template-based Coroutine continuation idea by Ross Bencina <rossb@audiomulch.com> May 2014.
// see: https://groups.google.com/forum/#!topic/comp.lang.c++.moderated/ryhWI6cX3Ko
#include <iostream>
class MyCoroutine {
typedef MyCoroutine this_t;
typedef bool (this_t::*coroutine_fn_t) ();
coroutine_fn_t next_;
You can’t perform that action at this time.