summaryrefslogtreecommitdiff
path: root/graphs/cpp/ref_swap/ref_swap.cc
blob: 44cb203969623646b03ed18e690f87d7f69249e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
//
// Created by martial.simon on 2/24/25.
//
void ref_swap(int& a, int& b)
{
    int tmp = a;
    a = b;
    b = tmp;
}

void ptr_swap(int* a, int* b)
{
    if (!a || !b)
        return;
    int tmp = *a;
    *a = *b;
    *b = tmp;
}