Skip to content

Commit

Permalink
Using defaulted equality operator where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-sparus committed May 15, 2024
1 parent dcf782c commit 569a12c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 42 deletions.
20 changes: 2 additions & 18 deletions immer/extra/archive/champ/archive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,8 @@ struct inner_node_save
bitmap_t datamap;
bool collisions{false};

auto tie() const
{
return std::tie(values, children, nodemap, datamap, collisions);
}

friend bool operator==(const inner_node_save& left,
const inner_node_save& right)
{
return left.tie() == right.tie();
}
const inner_node_save& right) = default;

template <class Archive>
void save(Archive& ar) const
Expand All @@ -58,16 +50,8 @@ struct inner_node_load
bitmap_t datamap;
bool collisions{false};

auto tie() const
{
return std::tie(values, children, nodemap, datamap, collisions);
}

friend bool operator==(const inner_node_load& left,
const inner_node_load& right)
{
return left.tie() == right.tie();
}
const inner_node_load& right) = default;

template <class Archive>
void load(Archive& ar)
Expand Down
8 changes: 2 additions & 6 deletions immer/extra/archive/common/archive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,8 @@ struct values_save
const T* begin = nullptr;
const T* end = nullptr;

auto tie() const { return std::tie(begin, end); }

friend bool operator==(const values_save& left, const values_save& right)
{
return left.tie() == right.tie();
}
friend bool operator==(const values_save& left,
const values_save& right) = default;
};

template <class T>
Expand Down
24 changes: 6 additions & 18 deletions immer/extra/archive/rbts/archive.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,8 @@ struct inner_node
immer::vector<node_id> children;
bool relaxed = {};

auto tie() const { return std::tie(children, relaxed); }

friend bool operator==(const inner_node& left, const inner_node& right)
{
return left.tie() == right.tie();
}
friend bool operator==(const inner_node& left,
const inner_node& right) = default;

template <class Archive>
void serialize(Archive& ar)
Expand All @@ -38,12 +34,8 @@ struct rbts_info
node_id root;
node_id tail;

auto tie() const { return std::tie(root, tail); }

friend bool operator==(const rbts_info& left, const rbts_info& right)
{
return left.tie() == right.tie();
}
friend bool operator==(const rbts_info& left,
const rbts_info& right) = default;

template <class Archive>
void serialize(Archive& ar)
Expand Down Expand Up @@ -110,12 +102,8 @@ struct archive_load
immer::map<node_id, inner_node> inners;
immer::vector<rbts_info> vectors;

auto tie() const { return std::tie(leaves, inners, vectors); }

friend bool operator==(const archive_load& left, const archive_load& right)
{
return left.tie() == right.tie();
}
friend bool operator==(const archive_load& left,
const archive_load& right) = default;

template <class Archive>
void load(Archive& ar)
Expand Down

0 comments on commit 569a12c

Please sign in to comment.