ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
detray::ranges::single_view< value_t > Class Template Reference

Struct that implements a view on a single element. More...

#include <detray/utils/ranges/single.hpp>

Inheritance diagram for detray::ranges::single_view< value_t >:
[legend]
Collaboration diagram for detray::ranges::single_view< value_t >:
[legend]

Public Types

using iterator_t = value_t*
 Pointer iterator over the single stored element.

Public Member Functions

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.
Public Member Functions inherited from detray::ranges::view_interface< single_view< value_t > >
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 Public Member Functions

static constexpr auto size () noexcept -> std::size_t

Detailed Description

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_ttype 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.

Constructor & Destructor Documentation

◆ single_view() [1/3]

template<typename value_t>
detray::ranges::single_view< value_t >::single_view ( const value_t & value)
explicitconstexpr

Construct the view by copying its single element.

Store a copy of value as the view's only element.

Parameters
valuevalue to copy into the view

◆ single_view() [2/3]

template<typename value_t>
detray::ranges::single_view< value_t >::single_view ( value_t && value)
explicitconstexpr

Construct the view by moving in its single element.

Move value into the view's only element.

Parameters
valuevalue to move into the view

◆ single_view() [3/3]

template<typename value_t>
template<class... Args>
detray::ranges::single_view< value_t >::single_view ( std::in_place_t ,
Args &&... args )
explicitconstexpr

Construct value in place from args.

Template Parameters
Argsargument types used to construct the value
Parameters
argsarguments forwarded to the value constructor

Member Function Documentation

◆ back()

template<typename value_t>
auto detray::ranges::single_view< value_t >::back ( ) ->value_t
constexprnoexcept
Returns
the value directly

◆ begin() [1/2]

template<typename value_t>
auto detray::ranges::single_view< value_t >::begin ( ) const->constvalue_t *
constexprnoexcept
Returns
value pointer - const

◆ begin() [2/2]

template<typename value_t>
auto detray::ranges::single_view< value_t >::begin ( ) ->value_t *
constexprnoexcept
Returns
value pointer.

◆ data() [1/2]

template<typename value_t>
auto detray::ranges::single_view< value_t >::data ( ) const->constvalue_t *
constexprnoexcept
Returns
a pointer to the beginning of the data - const

◆ data() [2/2]

template<typename value_t>
auto detray::ranges::single_view< value_t >::data ( ) ->value_t *
constexprnoexcept
Returns
a pointer to the beginning of the data

◆ end() [1/2]

template<typename value_t>
auto detray::ranges::single_view< value_t >::end ( ) const->constvalue_t *
constexprnoexcept
Returns
sentinel position - const

◆ end() [2/2]

template<typename value_t>
auto detray::ranges::single_view< value_t >::end ( ) ->value_t *
constexprnoexcept
Returns
sentinel position.

◆ front()

template<typename value_t>
auto detray::ranges::single_view< value_t >::front ( ) ->value_t
constexprnoexcept
Returns
the value directly

◆ operator[]()

template<typename value_t>
auto detray::ranges::single_view< value_t >::operator[] ( const dindex ) const->value_t
constexpr
Returns
the value directly

◆ ref() [1/2]

template<typename value_t>
auto detray::ranges::single_view< value_t >::ref ( ) ->value_t &
constexpr

Return a mutable reference to the stored element.

Returns
A mutable reference to the element.

◆ ref() [2/2]

template<typename value_t>
auto detray::ranges::single_view< value_t >::ref ( ) const->constvalue_t &
constexpr

Return a const reference to the stored element.

Returns
the single value

◆ size()

template<typename value_t>
constexpr auto detray::ranges::single_view< value_t >::size ( ) ->std::size_t
staticconstexprnoexcept
Returns
the size of the single view, which is always 'one'.

◆ value()

template<typename value_t>
auto detray::ranges::single_view< value_t >::value ( ) const->value_t
constexpr

Return the single stored value by value.

Returns
the single value