Skip to content

Commit 5028c3e

Browse files
committed
Add iterator assert
1 parent b266a6a commit 5028c3e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

yoga/node/Node.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,11 @@ class YG_EXPORT Node : public ::YGNode {
3535
public:
3636
using Backtrack = std::vector<std::pair<const Node*, size_t>>;
3737
struct Iterator {
38-
using iterator_category = std::forward_iterator_tag;
38+
using iterator_category = std::input_iterator_tag;
39+
using difference_type = std::ptrdiff_t;
40+
using value_type = Node*;
41+
using pointer = Node*;
42+
using reference = Node*;
3943

4044
Iterator(const Node* node, size_t childIndex)
4145
: node_(node), childIndex_(childIndex) {}
@@ -133,7 +137,9 @@ class YG_EXPORT Node : public ::YGNode {
133137
friend LayoutableChildren;
134138
};
135139

136-
LayoutableChildren(const Node* node) : node_(node) {}
140+
LayoutableChildren(const Node* node) : node_(node) {
141+
static_assert(std::input_iterator<LayoutableChildren::Iterator>);
142+
}
137143

138144
Iterator begin() const {
139145
if (node_->getChildCount() > 0) {
@@ -267,6 +273,7 @@ class YG_EXPORT Node : public ::YGNode {
267273
}
268274

269275
const LayoutableChildren getLayoutChildren() const {
276+
static_assert(std::input_iterator<LayoutableChildren::Iterator>);
270277
return LayoutableChildren(this);
271278
}
272279

0 commit comments

Comments
 (0)