A friend of mine asked me to source him a DPDT toggle switch for his layout. This was required to switch polarity on a triangle siding he had fitted into his route.
I was looking at the wiring diagram he had faxed me when it occurred to me that his system was DCC, and I thought that DCC was supposed to automatically sort out situations like this and that swapping the track polarity was probably not a good idea.
Even in DCC, you still can't connect the "A" rail to the "B" rail without some kind of switching.
As other have stated, you can get auto reverse modules that will do this automatically.
If he's running sound locos, the much longer break in the circuit as you switch manually will play havoc, causing the sound decoder to go through it's startup sequence again. foe the same reason you should avoid relay based auto-reverers as they are often slow and you may find the command station trips out before the revereser operates.
The autoreverser works by detecting a short circuit if the switched section is currently at the wrong polarity and very quickly changing the polarity to match that of the section the train is coming from. When the train leaves the switched section, the polarity will change again to math the exit tracks.
It's very important that the train cannot bridge between both entry and exit sections and the switched section at the same time. The simplest advice is to make the switched section longer than any train but this rule can be relaxed if you know the nature of all trains that will run through it (e.g. does the train have electrically linked axles for carriage lighting?)
It can be done manually with a switch, though as others have said an auto-reversing module is the "standard DCC" automated way to do things.
A manual switch or a relay is considerably cheaper. If the triangle-siding is a dead-end siding (or fan of sidings) and only accessed from the triangle, then a switch or relay tied to the direction of the turnouts leaving the triangle will do the job (on their outputs, most auto reversing modules have a relay to switch the track polarity).