C++ template to simplify BSERIALIZER function definition