1 #ifndef GEOS_COMMON_STD_CONTAINER_WRAPPERS_HPP
2 #define GEOS_COMMON_STD_CONTAINER_WRAPPERS_HPP
6 #include <unordered_map>
26 typename Allocator = std::allocator< T >,
27 bool USE_STD_CONTAINER_BOUNDS_CHECKING =
false
29 class StdVectorWrapper :
public std::vector< T, Allocator >
33 using Base = std::vector< T, Allocator >;
44 StdVectorWrapper(
size_t const count, T
const & value ):
53 StdVectorWrapper( Base
const & other ):
61 StdVectorWrapper( Base && other ):
62 Base( std::move( other ) )
71 T
const & operator[](
size_t const index )
const
73 if constexpr (USE_STD_CONTAINER_BOUNDS_CHECKING)
75 if( index >= this->size() )
77 std::cout<<
"Index out of bounds in StdVectorWrapper::operator[]: index = " + std::to_string( index ) +
", size = " + std::to_string( this->size());
79 return Base::at( index );
83 return Base::operator[]( index );
93 T & operator[](
size_t const index )
95 if constexpr (USE_STD_CONTAINER_BOUNDS_CHECKING)
97 if( index >= this->size() )
99 std::cout<<
"Index out of bounds in StdVectorWrapper::operator[]: index = " + std::to_string( index ) +
", size = " + std::to_string( this->size());
101 return Base::at( index );
105 return Base::operator[]( index );
111 #if defined( GEOS_USE_BOUNDS_CHECK )
117 template<
typename T,
typename Allocator = std::allocator< T > >
118 using stdVector = internal::StdVectorWrapper< T, Allocator, true >;
125 template<
typename T,
typename Allocator = std::allocator< T > >
std::vector< T, Allocator > stdVector