Skip to content

Commit 759a3ef

Browse files
committed
Revert to inheritance and use namespace scope relops
1 parent 6f049a1 commit 759a3ef

1 file changed

Lines changed: 31 additions & 31 deletions

File tree

test/rvariant/truly_recursive_test.cpp

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -143,45 +143,45 @@ struct NodeArray;
143143

144144
using Node = iris::rvariant<int, iris::recursive_wrapper<NodeArray>>;
145145

146-
struct NodeArray
146+
struct NodeArray : std::vector<Node>
147147
{
148-
std::vector<Node> vec;
148+
using std::vector<Node>::vector;
149+
};
149150

150-
bool operator==(NodeArray const& other) const
151-
{
152-
return vec == other.vec;
153-
}
151+
bool operator==(NodeArray const& a, NodeArray const& b)
152+
{
153+
return static_cast<std::vector<Node> const&>(a) == static_cast<std::vector<Node> const&>(b);
154+
}
154155

155-
bool operator!=(NodeArray const& other) const
156-
{
157-
return vec != other.vec;
158-
}
156+
bool operator!=(NodeArray const& a, NodeArray const& b)
157+
{
158+
return static_cast<std::vector<Node> const&>(a) != static_cast<std::vector<Node> const&>(b);
159+
}
159160

160-
bool operator<(NodeArray const& other) const
161-
{
162-
return vec < other.vec;
163-
}
161+
bool operator<(NodeArray const& a, NodeArray const& b)
162+
{
163+
return static_cast<std::vector<Node> const&>(a) < static_cast<std::vector<Node> const&>(b);
164+
}
164165

165-
bool operator>(NodeArray const& other) const
166-
{
167-
return vec > other.vec;
168-
}
166+
bool operator>(NodeArray const& a, NodeArray const& b)
167+
{
168+
return static_cast<std::vector<Node> const&>(a) > static_cast<std::vector<Node> const&>(b);
169+
}
169170

170-
bool operator<=(NodeArray const& other) const
171-
{
172-
return vec <= other.vec;
173-
}
171+
bool operator<=(NodeArray const& a, NodeArray const& b)
172+
{
173+
return static_cast<std::vector<Node> const&>(a) <= static_cast<std::vector<Node> const&>(b);
174+
}
174175

175-
bool operator>=(NodeArray const& other) const
176-
{
177-
return vec >= other.vec;
178-
}
176+
bool operator>=(NodeArray const& a, NodeArray const& b)
177+
{
178+
return static_cast<std::vector<Node> const&>(a) >= static_cast<std::vector<Node> const&>(b);
179+
}
179180

180-
auto operator<=>(NodeArray const& other) const
181-
{
182-
return vec <=> other.vec;
183-
}
184-
};
181+
auto operator<=>(NodeArray const& a, NodeArray const& b)
182+
{
183+
return static_cast<std::vector<Node> const&>(a) <=> static_cast<std::vector<Node> const&>(b);
184+
}
185185

186186
} // anonymous
187187

0 commit comments

Comments
 (0)