Celeritas  0.5.0-56+6b053cd
Public Member Functions | List of all members
celeritas::ContainerVisitor< T, U > Class Template Reference

Visit a container's element by calling "visit" on the corresponding index. More...

#include <VariantUtils.hh>

Public Types

Type aliases
using index_type = U
 

Public Member Functions

 ContainerVisitor (T &&container)
 Construct with a container.
 
template<class F >
decltype(auto) operator() (F &&func, U const &idx) const
 Visit the functor upon the value at the given index.
 

Detailed Description

template<class T, class U = typename std::remove_reference_t<T>::size_type>
class celeritas::ContainerVisitor< T, U >

Visit a container's element by calling "visit" on the corresponding index.

example:

std::vector<std::variant<int, std:string>> myvec{"hi", 123, "bye"};
ContainerVisitor visit_element{myvec};
visit_element([](auto&& v) { cout << v; }, 1); // Prints '123'
visit_element([](auto&& v) { cout << v; }, 2); // Prints 'bye'
ContainerVisitor(T &&container)
Construct with a container.
Definition: VariantUtils.hh:97

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