Skip to content

Instantly share code, notes, and snippets.

@tapeshmittal
tapeshmittal / Bind.cxx
Created September 17, 2019 20:46 — forked from Redchards/Bind.cxx
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.
@tapeshmittal
tapeshmittal / tuple.cpp
Created June 20, 2019 20:03 — forked from IvanVergiliev/tuple.cpp
C++ Tuple implementation
#include <cstdio>
template<typename First, typename... Rest>
struct Tuple: public Tuple<Rest...> {
Tuple(First first, Rest... rest): Tuple<Rest...>(rest...), first(first) {}
First first;
};
template<typename First>
/*****************************************************************************
* QuantCup 1: Price-Time Matching Engine
*
* Submitted by: voyager
*
* Design Overview:
* In this implementation, the limit order book is represented using
* a flat linear array (pricePoints), indexed by the numeric price value.
* Each entry in this array corresponds to a specific price point and holds
* an instance of struct pricePoint. This data structure maintains a list
@tapeshmittal
tapeshmittal / ObserverPattern.cpp
Created June 3, 2019 21:46 — forked from silahian/ObserverPattern.cpp
Observer pattern created by silahian - https://repl.it/HpbL/15
#include <string>
#include <vector>
#include <thread>
#include <iostream>
#include <unistd.h>
using namespace std;
class IObserver
{
public:
@tapeshmittal
tapeshmittal / MemoryAllocationHFT.cpp
Created June 3, 2019 21:44 — forked from silahian/MemoryAllocationHFT.cpp
Pre allocated vs dynamic arrays performance for low latency / high frequency trading systems
// Example program
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <time.h>
// ***********************************
// This is for measuring CPU clocks
#if defined(__i386__)
static __inline__ unsigned long long rdtsc(void)