OGS
BaseLib::detail::CovariantRandomAccessContainerView< Element, Container > Struct Template Referencefinal

Detailed Description

template<typename Element, typename Container>
struct BaseLib::detail::CovariantRandomAccessContainerView< Element, Container >

Definition at line 145 of file ContainerTools.h.

#include <ContainerTools.h>

Inheritance diagram for BaseLib::detail::CovariantRandomAccessContainerView< Element, Container >:
[legend]
Collaboration diagram for BaseLib::detail::CovariantRandomAccessContainerView< Element, Container >:
[legend]

Public Member Functions

 CovariantRandomAccessContainerView (Container &container)
Element & operator[] (std::size_t index) const override
std::size_t size () const noexcept override
Public Member Functions inherited from BaseLib::detail::PolymorphicRandomAccessContainerViewInterface< Element >
PolymorphicRandomAccessContainerViewIterator< Element > begin () const noexcept
PolymorphicRandomAccessContainerViewIterator< Element > end () const noexcept
virtual ~PolymorphicRandomAccessContainerViewInterface ()=default

Private Attributes

Container & container_

Constructor & Destructor Documentation

◆ CovariantRandomAccessContainerView()

template<typename Element, typename Container>
BaseLib::detail::CovariantRandomAccessContainerView< Element, Container >::CovariantRandomAccessContainerView ( Container & container)
inlineexplicit

Member Function Documentation

◆ operator[]()

template<typename Element, typename Container>
Element & BaseLib::detail::CovariantRandomAccessContainerView< Element, Container >::operator[] ( std::size_t index) const
inlineoverridevirtual

Implements BaseLib::detail::PolymorphicRandomAccessContainerViewInterface< Element >.

Definition at line 153 of file ContainerTools.h.

154 {
155 if constexpr (requires {
157 })
158 {
159 static_assert(
161 Element>);
162
163 return *container_[index];
164 }
165 else
166 {
167 static_assert(
169
170 // this restriction is necessary because of the constness
171 // propagation of std::vector.
172 static_assert(
174 "If the element type is non-const, the container must be "
175 "non-const, too.");
176
177 return container_[index];
178 }
179 }

References container_.

◆ size()

template<typename Element, typename Container>
std::size_t BaseLib::detail::CovariantRandomAccessContainerView< Element, Container >::size ( ) const
inlineoverridevirtualnoexcept

Implements BaseLib::detail::PolymorphicRandomAccessContainerViewInterface< Element >.

Definition at line 181 of file ContainerTools.h.

181{ return container_.size(); }

References container_.

Member Data Documentation

◆ container_

template<typename Element, typename Container>
Container& BaseLib::detail::CovariantRandomAccessContainerView< Element, Container >::container_
private

Definition at line 184 of file ContainerTools.h.

Referenced by CovariantRandomAccessContainerView(), operator[](), and size().


The documentation for this struct was generated from the following file: