Index: courgette/instruction_utils.h |
diff --git a/courgette/instruction_utils.h b/courgette/instruction_utils.h |
index d7dfe97e46625d24e61cb6fffbd44c68adbea9f2..df12aa6e23979b8aa178c326d3c48e8a1f82ecc1 100644 |
--- a/courgette/instruction_utils.h |
+++ b/courgette/instruction_utils.h |
@@ -61,6 +61,20 @@ class InstructionReceptor { |
// true on success, and false otherwise. |
using InstructionGenerator = base::Callback<CheckBool(InstructionReceptor*)>; |
+// A counter that increments via .push_back(), so it can be passed via template |
+// to substitute std::vector<T>, to count elements instead of storing them. |
+template <typename T> |
+class CountingVector { |
+ public: |
+ CountingVector() {} |
+ |
+ void push_back(const T& /* unused */) { ++size_; } |
+ size_t size() const { return size_; } |
+ |
+ private: |
+ size_t size_ = 0; |
+}; |
+ |
} // namespace courgette |
#endif // COURGETTE_INSTRUCTION_UTILS_H_ |