// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 #pragma once #include namespace krakatoa { namespace detail { template class collection_interface_traits { public: typedef T& return_type; typedef const T& const_return_type; }; } // namespace detail template > class collection_interface { protected: typedef Traits traits_type; public: typedef typename traits_type::return_type return_type; typedef typename traits_type::const_return_type const_return_type; public: virtual ~collection_interface() {} virtual std::size_t size() const = 0; virtual return_type get( int index ) = 0; virtual const_return_type get( int index ) const = 0; }; template class Container, class Allocator = std::allocator> class collection_wrapper : public Container, public collection_interface { public: virtual ~collection_wrapper() {} virtual std::size_t size() const { return static_cast*>( this )->size(); } virtual typename collection_interface::return_type get( int index ) { return ( *static_cast*>( this ) )[index]; } virtual typename collection_interface::const_return_type get( int index ) const { return ( *static_cast*>( this ) )[index]; } }; } // namespace krakatoa