Generic programming for SharedBuffer