Toronto has a rental demolition/conversion replacement by-law... Mississauga just passed one. These by-law can require the developer to provide affordable replacement housing or provide cash-in-lieu towards the City's affordable housing program.
https://yoursay.mississauga.ca/rental-housing