summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2025-03-22 13:01:14 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2025-03-22 13:01:14 +0000
commit163c8f75265054a168cc1e2750a0adb40fb08d83 (patch)
tree3f5aeb2c912fe079029e53fcd5aa29e5f245c814 /lib
parentInvert how shared/unique is specified for Collection (diff)
downloadilt-163c8f75265054a168cc1e2750a0adb40fb08d83.tar.bz2
ilt-163c8f75265054a168cc1e2750a0adb40fb08d83.tar.xz
ilt-163c8f75265054a168cc1e2750a0adb40fb08d83.zip
Make Collections::objects protected, extend interface
Keeps all required features accessible, but through a controlled interface.
Diffstat (limited to 'lib')
-rw-r--r--lib/collection.h44
1 files changed, 41 insertions, 3 deletions
diff --git a/lib/collection.h b/lib/collection.h
index 2deefb9..c843bad 100644
--- a/lib/collection.h
+++ b/lib/collection.h
@@ -12,7 +12,19 @@ public:
using Object = Ptr::element_type;
using Objects = std::vector<Ptr>;
- Objects objects;
+
+ Collection &
+ operator=(Objects && other)
+ {
+ objects = std::move(other);
+ return *this;
+ }
+
+ const Ptr &
+ operator[](size_t idx) const
+ {
+ return objects[idx];
+ }
template<typename T = Object, typename... Params>
auto
@@ -91,19 +103,45 @@ public:
});
}
- auto
+ [[nodiscard]] auto
+ begin() const
+ {
+ return objects.begin();
+ }
+
+ [[nodiscard]] auto
end() const
{
return objects.end();
}
- auto
+ [[nodiscard]] auto
+ rbegin() const
+ {
+ return objects.rbegin();
+ }
+
+ [[nodiscard]] auto
rend() const
{
return objects.rend();
}
+ [[nodiscard]] bool
+ empty() const
+ {
+ return objects.empty();
+ }
+
+ auto
+ emplace(Ptr && ptr)
+ {
+ return objects.emplace_back(std::move(ptr));
+ }
+
protected:
+ Objects objects;
+
template<typename T = Object, typename... Params>
auto
apply_internal(const auto begin, const auto end, const auto & m, Params &&... params) const