more MaterializedTupleRef refactoring and a new copy constructor
add cstring header and change some c headers to c++ headers
mv mat template
include static assert in the new T copy constructor
fix base_template shadowing bug, and make base_template() a cls member