A generic segment tree C++ implementation