Implementation of template bag class