Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For swap use ADL instead of specializing std::swap #3656

Merged
merged 1 commit into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/lib/math/bigint/bigint.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,8 @@ class BOTAN_PUBLIC_API(2, 0) BigInt final {
std::swap(m_signedness, other.m_signedness);
}

friend void swap(BigInt& x, BigInt& y) { x.swap(y); }

void swap_reg(secure_vector<word>& reg) {
m_data.swap(reg);
// sign left unchanged
Expand Down Expand Up @@ -1034,13 +1036,4 @@ BOTAN_PUBLIC_API(2, 0) std::istream& operator>>(std::istream&, BigInt&);

} // namespace Botan

namespace std {

template <>
inline void swap<Botan::BigInt>(Botan::BigInt& x, Botan::BigInt& y) {
x.swap(y);
}

} // namespace std

#endif
11 changes: 2 additions & 9 deletions src/lib/pubkey/ec_group/curve_gfp.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,8 @@ class BOTAN_UNSTABLE_API CurveGFp final {

void swap(CurveGFp& other) { std::swap(m_repr, other.m_repr); }

friend void swap(CurveGFp& x, CurveGFp& y) { x.swap(y); }

/**
* Equality operator
* @param other a curve
Expand All @@ -204,13 +206,4 @@ inline bool operator!=(const CurveGFp& lhs, const CurveGFp& rhs) {

} // namespace Botan

namespace std {

template <>
inline void swap<Botan::CurveGFp>(Botan::CurveGFp& curve1, Botan::CurveGFp& curve2) noexcept {
curve1.swap(curve2);
}

} // namespace std

#endif
11 changes: 2 additions & 9 deletions src/lib/pubkey/ec_group/ec_point.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,8 @@ class BOTAN_PUBLIC_API(2, 0) EC_Point final {
*/
void swap(EC_Point& other);

friend void swap(EC_Point& x, EC_Point& y) { x.swap(y); }

/**
* Randomize the point representation
* The actual value (get_affine_x, get_affine_y) does not change
Expand Down Expand Up @@ -401,13 +403,4 @@ typedef EC_Point PointGFp;

} // namespace Botan

namespace std {

template <>
inline void swap<Botan::EC_Point>(Botan::EC_Point& x, Botan::EC_Point& y) {
x.swap(y);
}

} // namespace std

#endif