OpenKalman
Namespaces | Classes | Typedefs | Functions | Variables
OpenKalman::collections Namespace Reference

Namespace for collections. More...

Namespaces

 detail_sized
 An object (std::ranges::sized_range, std::tuple, std::span, etc.) that has a discernible size.
 
 views
 Namespace for generalized views.
 

Classes

struct  common_collection_type
 The common type within a collection, if it exists. More...
 
struct  common_collection_type< T, std::enable_if_t< ranges::range< T > > >
 
struct  common_tuple_type
 The common type within a tuple_like object, if it exists. More...
 
struct  common_tuple_type< T, std::enable_if_t< tuple_like< T > > >
 
struct  concat_tuple_view
 A view to a concatenation of some number of other tuple_like object. More...
 
struct  from_tuple
 A collection_view created from a uniform_tuple_like object. More...
 
struct  generate_view
 A collection_view created by lazily generating elements based on an index. More...
 
struct  iota_view
 An iota collection that is a std::range and may also be tuple_like. More...
 
struct  repeat_tuple_view
 A view of a tuple that replicates a particular value N number of times. More...
 
struct  replicate_view
 A view that replicates a collection some number of times. More...
 
struct  size_of
 The size of a sized object (including a collection). More...
 
struct  size_of< T, std::enable_if_t< values::fixed< decltype(get_size(std::declval< T >()))> > >
 
struct  slice_view
 A view representing a slice of a collection. More...
 
struct  to_tuple
 A collection_view created from a std::ranges::random_access_range that is a std::ranges::viewable_range. More...
 
struct  tuple_reverse_view
 A view of a tuple that reverses the order of a base tuple. More...
 
struct  tuple_slice_view
 A view to a slice of a tuple_like object. More...
 
struct  update_view
 A collection_view that updates an underlying collection_view on an element-by-element basis. More...
 

Typedefs

template<typename T >
using common_collection_type_t = typename common_collection_type< T >::type
 Helper template for common_collection_type.
 
template<typename T >
using common_tuple_type_t = typename common_tuple_type< T >::type
 Helper template for common_collection_type.
 

Functions

template<typename Lhs , typename Rhs , std::enable_if_t< detail::comparable< Lhs > and detail::comparable< Rhs >, int > = 0>
constexpr partial_ordering compare (const Lhs &lhs, const Rhs &rhs)
 Compare two collections.
 
template<typename Lhs , typename Rhs , std::enable_if_t< detail::comparable< Lhs > and detail::comparable< Rhs >, int > = 0>
constexpr bool operator== (const Lhs &lhs, const Rhs &rhs)
 
template<typename Lhs , typename Rhs , std::enable_if_t< detail::comparable< Lhs > and detail::comparable< Rhs >, int > = 0>
constexpr bool operator!= (const Lhs &lhs, const Rhs &rhs)
 
template<typename Lhs , typename Rhs , std::enable_if_t< detail::comparable< Lhs > and detail::comparable< Rhs >, int > = 0>
constexpr bool operator< (const Lhs &lhs, const Rhs &rhs)
 
template<typename Lhs , typename Rhs , std::enable_if_t< detail::comparable< Lhs > and detail::comparable< Rhs >, int > = 0>
constexpr bool operator> (const Lhs &lhs, const Rhs &rhs)
 
template<typename Lhs , typename Rhs , std::enable_if_t< detail::comparable< Lhs > and detail::comparable< Rhs >, int > = 0>
constexpr bool operator<= (const Lhs &lhs, const Rhs &rhs)
 
template<typename Lhs , typename Rhs , std::enable_if_t< detail::comparable< Lhs > and detail::comparable< Rhs >, int > = 0>
constexpr bool operator>= (const Lhs &lhs, const Rhs &rhs)
 
template<typename Arg , typename I , std::enable_if_t< collection< Arg > and values::index< I > and(ranges::random_access_range< Arg > or detail::gettable_with_i< Arg, I >), int > = 0>
decltype(auto) constexpr get (Arg &&arg, I i)
 A generalization of std::get. More...
 
template<typename Arg , std::enable_if_t< sized< Arg >, int > = 0>
constexpr auto get_size (Arg &&arg)
 Get the size of a sized object (e.g, a collection)
 
template<typename Arg , std::enable_if_t< tuple_like< Arg >, int > = 0>
constexpr auto tuple_flatten (Arg &&arg)
 
template<typename Arg >
 tuple_reverse_view (Arg &&) -> tuple_reverse_view< Arg >
 Deduction guide.
 
template<typename Arg , std::enable_if_t< tuple_like< Arg >, int > = 0>
constexpr auto tuple_reverse (Arg &&arg)
 Reverses the order of a tuple_like object.
 
template<typename T , std::enable_if_t< tuple_like< T > and std::is_default_constructible_v< T >, int > = 0>
constexpr auto tuple_reverse ()
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<std::size_t index1, std::size_t index2, typename Arg >
constexpr auto tuple_slice (Arg &&arg)
 Takes a slice of a tuple, given an index range. More...
 
template<std::size_t index1, std::size_t index2, typename T , std::enable_if_t< tuple_like< T > and std::is_default_constructible_v< T >, int > = 0>
constexpr auto tuple_slice ()
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename... Args>
 concat_tuple_view (Args &&...) -> concat_tuple_view< Args... >
 Deduction guide.
 
template<typename Tup >
 from_tuple (Tup &&) -> from_tuple< Tup >
 
template<typename F , typename S >
 generate_view (F &&, const S &) -> generate_view< F, S >
 Deduction guide.
 
template<typename F >
 generate_view (F &&) -> generate_view< F >
 
template<typename Start , typename Size >
 iota_view (const Start &, const Size &) -> iota_view< Start, Size >
 Deduction guide.
 
template<typename Size >
 iota_view (const Size &) -> iota_view< std::integral_constant< std::size_t, 0 >, Size >
 Deduction guide which assumes that omitting a Start parameter means that the sequence will start at zero.
 
template<typename V , typename F >
 replicate_view (const V &, const F &) -> replicate_view< V, F >
 Deduction guide.
 
template<typename V , typename O , typename E >
 slice_view (const V &, const O &, const E &) -> slice_view< V, O, E >
 Deduction guide.
 
template<typename V >
 to_tuple (V &&) -> to_tuple< V >
 
template<typename V , typename F >
 update_view (const V &, F &&) -> update_view< V, F >
 

Variables

template<typename T >
constexpr bool collection = ranges::random_access_range<T> or uniformly_gettable<T>
 An object describing a collection of objects. More...
 
template<typename T >
constexpr bool collection_view = ranges::view<T> and uniformly_gettable<T> and ranges::random_access_range<T>
 A view to a collection which is also a std::ranges:view. More...
 
template<std::size_t i, typename T >
constexpr bool gettable = detail::gettable_impl<i, T>::value
 T has an element i that is accessible by a get(...) function. More...
 
template<typename T >
constexpr bool index
 An object describing a collection of /ref values::index objects. More...
 
template<typename F , typename C , typename... Args>
constexpr bool invocable_on_collection
 Callable object F is invocable on each element of collection C, with additional parameters Args. More...
 
template<typename C , typename T >
constexpr bool output_collection = collection<C> and (ranges::output_range<C, T> or uniformly_settable<C, T>)
 A collection that can be modified on an element-by-element basis.
 
template<typename T >
constexpr bool sized_random_access_range = ranges::random_access_range<remove_cvref_t<T>> and sized<T>
 A sized random access range.
 
template<typename T >
constexpr bool tuple_like = uniformly_gettable<T> and detail::is_tuple_like<std::decay_t<T>>::value
 T is a non-empty tuple, pair, array, or other type that acts like a tuple. More...
 
template<typename T >
constexpr bool uniform_tuple_like = tuple_like<T> and (size_of_v<T> == 0 or detail::has_common_tuple_type<T>::value)
 A tuple_like object that has a common_collection_type.
 
template<typename T >
constexpr bool uniformly_gettable
 T is gettable for all indices. More...
 
template<typename C , typename T >
constexpr bool uniformly_settable
 C is settable with type C for all indices. More...
 
template<typename T >
constexpr bool viewable_collection
 A std::range or uniform_tuple_like object that can be converted into a collection_view by passing it to collections::views::all. More...
 
template<typename T >
constexpr std::size_t size_of_v = size_of<T>::value
 Helper for collections::size_of.
 

Detailed Description

Namespace for collections.

Function Documentation

◆ generate_view()

template<typename F >
OpenKalman::collections::generate_view ( F &&  ) -> generate_view< F >

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ get()

template<typename Arg , typename I , std::enable_if_t< collection< Arg > and values::index< I > and(ranges::random_access_range< Arg > or detail::gettable_with_i< Arg, I >), int > = 0>
decltype(auto) constexpr OpenKalman::collections::get ( Arg &&  arg,
i 
)

A generalization of std::get.

This function takes a values::value parameter instead of a template parameter like std::get.

  • If the argument has a get() member, call that member.
  • Otherwise, call get<i*gt;(std::forward<Arg>(arg)) if such a function is found using ADL.
  • Otherwise, call std::get<i*gt;(std::forward<Arg>(arg)) if it is defined.
  • Otherwise, call std::ranges::begin(std::forward<Arg>(arg)) if it is a valid call.

◆ tuple_slice()

template<std::size_t index1, std::size_t index2, typename Arg >
constexpr auto OpenKalman::collections::tuple_slice ( Arg &&  arg)

Takes a slice of a tuple, given an index range.

The function will copy or move elements from the argument tuple.

Template Parameters
index1The index of the beginning of the slice.
index2The first index just beyond the end of the slice.
Parameters
argThe tuple.
Returns
The tuple slice.

Variable Documentation

◆ collection

template<typename T >
constexpr bool OpenKalman::collections::collection = ranges::random_access_range<T> or uniformly_gettable<T>

An object describing a collection of objects.

This is either a uniforly gettable object or a std::ranges::random_access_range. It need not be sized. A sized collection is either tuple_like or sized_random_access_range.

◆ collection_view

template<typename T >
constexpr bool OpenKalman::collections::collection_view = ranges::view<T> and uniformly_gettable<T> and ranges::random_access_range<T>

A view to a collection which is also a std::ranges:view.

It may or may not be sized.

◆ gettable

template<std::size_t i, typename T >
constexpr bool OpenKalman::collections::gettable = detail::gettable_impl<i, T>::value

T has an element i that is accessible by a get(...) function.

C has an element i that can be set by assigning the result of a get(...) function to an object of type T.

The get(...) function can be std::get<i>(...), a get(...) member function, or a separately-defined matching get(...) function in T's namespace.

◆ index

template<typename T >
constexpr bool OpenKalman::collections::index
Initial value:
= collection<T> and
(detail_index::is_index_tuple<std::decay_t<T>>::value or detail_index::is_index_range<std::decay_t<T>>::value)
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31

An object describing a collection of /ref values::index objects.

This will be a tuple-like object or a dynamic range over a collection such as std::vector.

◆ invocable_on_collection

template<typename F , typename C , typename... Args>
constexpr bool OpenKalman::collections::invocable_on_collection
Initial value:
=
(not ranges::range<C> or detail::is_invocable_on_range<C, F, void, Args&&...>::value) and
(not tuple_like<C> or detail::is_invocable_on_tuple<C, F, typename detail::is_invocable_on_tuple_sequence<C>::type, Args&&...>::value)
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31

Callable object F is invocable on each element of collection C, with additional parameters Args.

◆ tuple_like

template<typename T >
constexpr bool OpenKalman::collections::tuple_like = uniformly_gettable<T> and detail::is_tuple_like<std::decay_t<T>>::value

T is a non-empty tuple, pair, array, or other type that acts like a tuple.

T has defined specializations for std::tuple_size and std::tuple_element, and the elements of T can be accessible by std::get(...), a get(...) member function, or an atd-findable get(...) function.

◆ uniformly_gettable

template<typename T >
constexpr bool OpenKalman::collections::uniformly_gettable
Initial value:
=
((sized<T> and size_of_v<T> != dynamic_size) or
(gettable<0_uz, T> and gettable<std::numeric_limits<std::size_t>::max() - 1_uz, T>)) and
(not sized<T> or size_of_v<T> == dynamic_size or detail::uniformly_gettable_sized<T>::value)
constexpr bool gettable
T has an element i that is accessible by a get(...) function.
Definition: gettable.hpp:58
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
constexpr std::size_t dynamic_size
A constant indicating that a size or index is dynamic.
Definition: global-definitions.hpp:33

T is gettable for all indices.

If T is not sized, then it must be gettable for at least index 0 and std::numeric_limits<std::size_t>::max() - 1.

◆ uniformly_settable

template<typename C , typename T >
constexpr bool OpenKalman::collections::uniformly_settable
Initial value:
=
((sized<C> and size_of_v<C> != dynamic_size) or
(settable<0_uz, C, T> and settable<std::numeric_limits<std::size_t>::max() - 1_uz, C, T>)) and
(not sized<C> or size_of_v<C> == dynamic_size or detail::uniformly_settable_sized<C, T>::value)
constexpr bool value
T is numerical value or is reducible to a numerical value.
Definition: value.hpp:31
constexpr std::size_t dynamic_size
A constant indicating that a size or index is dynamic.
Definition: global-definitions.hpp:33

C is settable with type C for all indices.

If C is not sized, then it must be settable for at least index 0 and std::numeric_limits<std::size_t>::max() - 1.

◆ viewable_collection

template<typename T >
constexpr bool OpenKalman::collections::viewable_collection
Initial value:
= (ranges::random_access_range<T> and
(ranges::view<remove_cvref_t<T>> or ranges::viewable_range<T>)) or uniform_tuple_like<T>

A std::range or uniform_tuple_like object that can be converted into a collection_view by passing it to collections::views::all.