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

Changed IPNetwork copy assignment implementation to copy-and-swap. #1681

Merged
merged 3 commits into from
Jan 9, 2025
Merged
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
26 changes: 4 additions & 22 deletions Common++/header/IpAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -707,18 +707,9 @@ namespace pcpp
/// @return A reference to the assignee
IPNetwork& operator=(const IPv4Network& other)
{
if (m_IPv4Network)
{
m_IPv4Network = nullptr;
}

if (m_IPv6Network)
{
m_IPv6Network = nullptr;
}

// Create the new instance first to maintain strong exception guarantee.
m_IPv4Network = std::unique_ptr<IPv4Network>(new IPv4Network(other));

m_IPv6Network = nullptr;
return *this;
}

Expand All @@ -727,18 +718,9 @@ namespace pcpp
/// @return A reference to the assignee
IPNetwork& operator=(const IPv6Network& other)
{
if (m_IPv4Network)
{
m_IPv4Network = nullptr;
}

if (m_IPv6Network)
{
m_IPv6Network = nullptr;
}

// Create the new instance first to maintain strong exception guarantee.
m_IPv6Network = std::unique_ptr<IPv6Network>(new IPv6Network(other));

m_IPv4Network = nullptr;
return *this;
}

Expand Down
Loading