You can not do this in a registered account like rrsp or tfsa.

this is not the same as selling and taking capital loss.

you have to sell, wait 30 days and buy it next year.

its kind of a tax loophole and it can be very advantageous.