Skip to content

Commit 27bf755

Browse files
committed
Add more [[nodiscard]] attributes to traverser.
1 parent 0b1c9f4 commit 27bf755

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

include/noarr/structures/extra/traverser.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,10 @@ template<class Struct, class Order>
117117
struct traverser_t : contain<Struct, Order> {
118118
using contain<Struct, Order>::contain;
119119

120+
[[nodiscard("returns a copy of the underlying struct")]]
120121
constexpr auto get_struct() const noexcept { return this->template get<0>(); }
122+
123+
[[nodiscard("returns a copy of the underlying order")]]
121124
constexpr auto get_order() const noexcept { return this->template get<1>(); }
122125

123126
[[nodiscard("returns a new traverser")]]
@@ -152,10 +155,12 @@ struct traverser_t : contain<Struct, Order> {
152155
for_each_impl(dim_tree_from_sequence<dim_sequence<Dims...>>(), f, empty_state);
153156
}
154157

158+
[[nodiscard("construct an object representing the state of the traverser")]]
155159
constexpr auto state() const noexcept {
156160
return state_at<Struct>(top_struct(), empty_state);
157161
}
158162

163+
[[nodiscard("returns a copy of the top struct (combination of the underlying struct and order)")]]
159164
constexpr auto top_struct() const noexcept {
160165
return get_struct() ^ get_order();
161166
}
@@ -219,6 +224,7 @@ template<class T>
219224
concept IsTraverser = is_traverser_v<T>;
220225

221226
template<IsTraverser T>
227+
[[nodiscard("returns a new traverser")]]
222228
constexpr auto operator^(const T &t, IsProtoStruct auto order) noexcept {
223229
return t.order(order);
224230
}

0 commit comments

Comments
 (0)