Codechange: Remove ReferenceThroughBaseContainer

This commit is contained in:
Jonathan G Rennison 2025-06-08 20:47:17 +01:00 committed by Peter Nelson
parent 63f1c2aa3a
commit d3e4e07daa

View File

@ -29,26 +29,6 @@ concept ConvertibleThroughBase = requires(T const a) {
template <typename T, typename TTo>
concept ConvertibleThroughBaseOrTo = std::is_convertible_v<T, TTo> || ConvertibleThroughBase<T>;
/**
* A sort-of mixin that adds 'at(pos)' and 'operator[](pos)' implementations for 'ConvertibleThroughBase' types.
* This to prevent having to call '.base()' for many container accesses.
*/
template <typename Container>
class ReferenceThroughBaseContainer : public Container {
public:
Container::reference at(size_t pos) { return this->Container::at(pos); }
Container::reference at(const ConvertibleThroughBase auto &pos) { return this->Container::at(pos.base()); }
Container::const_reference at(size_t pos) const { return this->Container::at(pos); }
Container::const_reference at(const ConvertibleThroughBase auto &pos) const { return this->Container::at(pos.base()); }
Container::reference operator[](size_t pos) { return this->Container::operator[](pos); }
Container::reference operator[](const ConvertibleThroughBase auto &pos) { return this->Container::operator[](pos.base()); }
Container::const_reference operator[](size_t pos) const { return this->Container::operator[](pos); }
Container::const_reference operator[](const ConvertibleThroughBase auto &pos) const { return this->Container::operator[](pos.base()); }
};
/**
* A sort-of mixin that implements 'at(pos)' and 'operator[](pos)' only for a specific type.
* The type must have a suitable '.base()' method and therefore must inherently match 'ConvertibleThroughBase'.