Struct that implements a view on a single element.
More...
#include <detray/utils/ranges/single.hpp>
|
|
using | iterator_t = value_t* |
| | Pointer iterator over the single stored element.
|
|
|
constexpr | single_view ()=default |
| | Default constructor.
|
| constexpr | single_view (const value_t &value) |
| | Construct the view by copying its single element.
|
| template<class... Args> |
| constexpr | single_view (std::in_place_t, Args &&... args) |
| | Construct value in place from args.
|
| constexpr | single_view (value_t &&value) |
| | Construct the view by moving in its single element.
|
| constexpr auto | back () noexcept -> value_t |
| constexpr auto | begin () const noexcept -> const value_t * |
| constexpr auto | begin () noexcept -> value_t * |
| constexpr auto | data () const noexcept -> const value_t * |
| constexpr auto | data () noexcept -> value_t * |
| constexpr auto | end () const noexcept -> const value_t * |
| constexpr auto | end () noexcept -> value_t * |
| constexpr auto | front () noexcept -> value_t |
| constexpr auto | operator[] (const dindex) const -> value_t |
| constexpr auto | ref () -> value_t & |
| | Return a mutable reference to the stored element.
|
| constexpr auto | ref () const -> const value_t & |
| | Return a const reference to the stored element.
|
| constexpr auto | value () const -> value_t |
| | Return the single stored value by value.
|
| constexpr decltype(auto) | back () const |
| | Return a reference to the last element.
|
| constexpr auto | data () const |
| | Return a pointer to the first element, or null for an empty view.
|
| constexpr auto | empty () const -> bool |
| | Check whether the view contains no elements.
|
| constexpr decltype(auto) | front () const |
| | Return a reference to the first element.
|
| constexpr | operator bool () const |
| | Test whether the view contains at least one element.
|
| constexpr decltype(auto) | operator[] (const dindex i) const |
| | Subscript operator that takes detray dindex.
|
| constexpr auto | size () const |
| | Return the number of elements in the view.
|
|
| static constexpr auto | size () noexcept -> std::size_t |
template<typename value_t>
class detray::ranges::single_view< value_t >
Struct that implements a view on a single element.
- See also
- https://en.cppreference.com/w/cpp/ranges/single_view
- Template Parameters
-
| value_t | type of the single element (outside of a container) |
- Note
- Does not take ownership of the value it operates on. Its lifetime needs to be guaranteed throughout iteration or between iterations with the same view instance.
-
Is not fit for lazy evaluation.
◆ single_view() [1/3]
template<typename value_t>
Construct the view by copying its single element.
Store a copy of value as the view's only element.
- Parameters
-
| value | value to copy into the view |
◆ single_view() [2/3]
template<typename value_t>
Construct the view by moving in its single element.
Move value into the view's only element.
- Parameters
-
| value | value to move into the view |
◆ single_view() [3/3]
template<typename value_t>
template<class... Args>
Construct value in place from args.
- Template Parameters
-
| Args | argument types used to construct the value |
- Parameters
-
| args | arguments forwarded to the value constructor |
◆ back()
template<typename value_t>
- Returns
- the value directly
◆ begin() [1/2]
template<typename value_t>
- Returns
- value pointer - const
◆ begin() [2/2]
template<typename value_t>
◆ data() [1/2]
template<typename value_t>
- Returns
- a pointer to the beginning of the data - const
◆ data() [2/2]
template<typename value_t>
- Returns
- a pointer to the beginning of the data
◆ end() [1/2]
template<typename value_t>
- Returns
- sentinel position - const
◆ end() [2/2]
template<typename value_t>
- Returns
- sentinel position.
◆ front()
template<typename value_t>
- Returns
- the value directly
◆ operator[]()
template<typename value_t>
- Returns
- the value directly
◆ ref() [1/2]
template<typename value_t>
Return a mutable reference to the stored element.
- Returns
- A mutable reference to the element.
◆ ref() [2/2]
template<typename value_t>
Return a const reference to the stored element.
- Returns
- the single value
◆ size()
template<typename value_t>
- Returns
- the size of the single view, which is always 'one'.
◆ value()
template<typename value_t>
Return the single stored value by value.
- Returns
- the single value