Skip to content

Core (LV::IntrusivePtr): Implement swap() overload as a friend function.#218

Merged
kaixiong merged 1 commit intomasterfrom
c++-adl-swap
Jan 25, 2023
Merged

Core (LV::IntrusivePtr): Implement swap() overload as a friend function.#218
kaixiong merged 1 commit intomasterfrom
c++-adl-swap

Conversation

@kaixiong
Copy link
Copy Markdown
Member

Overloading of functions in std namespace is considered undefined behaviour by the C++ standard.

We do the Right Thing by changing LV::IntrusivePtr's swap() to a friend function that can be found using argument-dependent lookup.

…on to work with ADL. Overloading std::swap() is considered UB!
@kaixiong kaixiong self-assigned this Jan 25, 2023
@kaixiong kaixiong added the bug label Jan 25, 2023
@kaixiong kaixiong added this to the 0.5.0_alpha1 milestone Jan 25, 2023
@kaixiong kaixiong merged commit 5f0d93c into master Jan 25, 2023
@kaixiong kaixiong deleted the c++-adl-swap branch January 25, 2023 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant