#pragma once #include #include // Add more forwarding functions to the delegate std::vector as needed. namespace vcpkg { template class ImmutableSortedVector { public: static ImmutableSortedVector create(std::vector vector) { ImmutableSortedVector out; out.delegate = std::move(vector); if (!std::is_sorted(out.delegate.cbegin(), out.delegate.cend())) { std::sort(out.delegate.begin(), out.delegate.end()); } return out; } typename std::vector::const_iterator begin() const { return this->delegate.cbegin(); } typename std::vector::const_iterator end() const { return this->delegate.cend(); } typename std::vector::const_iterator cbegin() const { return this->delegate.cbegin(); } typename std::vector::const_iterator cend() const { return this->delegate.cend(); } private: std::vector delegate; }; }