#pragma once #include "comutil.h" namespace MSO { // CRTP for adding Collection access functions to wrapper classes template class MSCollection { public: using IndexType = long; using IndexString = CString; using size_type = long; // Note: Do not warn about static_cast downcast #pragma warning( push ) #pragma warning( disable : 26491 ) Item operator[](const IndexType& index) { auto* collection = static_cast(this); return collection->get_Item(_variant_t(index)); } Item operator[](const IndexString& index) { auto* collection = static_cast(this); return collection->get_Item(_variant_t(index)); } #pragma warning( pop ) size_type size() const { auto* collection = static_cast(this); return collection->GetCount(); } private: friend Collection; MSCollection() = default; }; } // namespace MSO