s-yata / marisa-trie

MARISA: Matching Algorithm with Recursively Implemented StorAge
Other
511 stars 89 forks source link

Fix `swap` overload #20

Closed glebm closed 5 years ago

glebm commented 6 years ago

Use std::swap instead of a custom version to avoid "ambiguous call" compile error with ADL.

For example, without this PR, the following code fails to compile with C++ 11:

std::unique_ptr<marisa::Trie> a;

// Here, `unique_ptr` calls `swap` internally using ADL.
// Previously, this failed to compile because of the conflict with `marisa::swap`:
a.reset(new marisa::Trie());

PR https://github.com/s-yata/marisa-trie/pull/17 by @NOMORECOFFEE also tried to fix this but it didn't have a C++ 98 fallback and got closed by its author.

s-yata commented 5 years ago

Thank you for your help!