Skip to content

Instantly share code, notes, and snippets.

View nbdd0121's full-sized avatar

Gary Guo nbdd0121

View GitHub Profile
@nbdd0121
nbdd0121 / decltype-test.cc
Created February 6, 2015 06:56
Test on degree of support of decltype on various compilers
#include <iostream>
template<typename T>
class Pointer{
private:
T* ptr_;
public:
Pointer(T* ptr): ptr_(ptr) {}
operator T*() const {
return ptr_;
@nbdd0121
nbdd0121 / mark-sweep-gc.cc
Created January 24, 2015 06:18
Simple mark-and-sweep GC (coded as a beginner of C++)
#include <iostream>
#include <vector>
#define debug(statement) statement
// #define debug(statement)
// Above one for release use
/* Declarations */
class GCObject;
@nbdd0121
nbdd0121 / Stream.js
Created December 24, 2014 12:19
Stream (like that of Java 8) for ES.next
class Stream {
constructor(content) {
this._content = content;
}
static from(arr) {
if (!arr[Symbol.iterator]) {
arr = Array.from(arr);
}
return new ArrayStream(arr);
}