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 138 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 146 of file ContainerTools.h.

147 {
148 if constexpr (requires {
150 })
151 {
152 static_assert(
154 Element>);
155
156 return *container_[index];
157 }
158 else
159 {
160 static_assert(
162
163 // this restriction is necessary because of the constness
164 // propagation of std::vector.
165 static_assert(
167 "If the element type is non-const, the container must be "
168 "non-const, too.");
169
170 return container_[index];
171 }
172 }

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 174 of file ContainerTools.h.

174{ 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 177 of file ContainerTools.h.

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


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