HELP WITH SWAP FUNTION

Does anyone know how to write the swap function in C++ but using references to pointers instead of pointers to pointers. ????
closed account (zb0S216C)
1
2
3
4
5
template <typename T>
void Switch(T *&A, T *&B)
{
    //...
}

Wazzak
Last edited on
1
2
3
4
5
6
7
template <typename T>
void swap(T*& a, T*&b)
{
        T* temp=a;
        a=b;
        b=temp;
        }

It's an overload of the regular std::swap function.
EDIT: the regular std::swap function can swap references to pointers without making a custom overload, so this is not needed!
Last edited on
Topic archived. No new replies allowed.