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  collection_element
 The type of the element at a given index, if it can be determined at compile time. More...
 
struct  collection_element< i, T, std::enable_if_t< values::size_compares_with< std::integral_constant< std::size_t, i >, size_of< T >, &stdex::is_lt > and detail::has_tuple_element< i, T >::value > >
 
struct  collection_element< i, T, std::enable_if_t< values::size_compares_with< std::integral_constant< std::size_t, i >, size_of< T >, &stdex::is_lt > and(not detail::has_tuple_element< i, T >::value) and gettable< i, T > > >
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
struct  collection_element< i, T, std::enable_if_t<(not values::size_compares_with< std::integral_constant< std::size_t, i >, size_of< T >, &stdex::is_lt >) and stdex::ranges::random_access_range< T > and not detail::has_tuple_element< i, T >::value and not gettable< i, T > > >
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
struct  common_collection_type
 The common type within a collection, if it exists. More...
 
struct  common_collection_type< T, std::enable_if_t< stdex::ranges::random_access_range< T > > >
 
struct  common_collection_type< T, std::enable_if_t< uniformly_gettable< T > and not stdex::ranges::random_access_range< T > > >
 
struct  concat_tuple_view
 A view to a concatenation of some number of other uniformly_gettable object. More...
 
struct  from_range
 A collection_view created from a std::ranges::random_access_range that is a std::ranges::viewable_range. More...
 
struct  from_tuple_like
 A collection_view created from a viewable_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 uniformly_gettable. More...
 
struct  repeat_tuple_view
 A uniformly_gettable view 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< sized< T > and not values::fixed< decltype(collections::get_size(std::declval< T >()))> > >
 
struct  size_of< T, std::enable_if_t< sized< T > and values::fixed< decltype(collections::get_size(std::declval< T >()))> > >
 
struct  slice_view
 A view representing a slice of a collection. More...
 
struct  tuple_reverse_view
 A view of a tuple that reverses the order of a base tuple. More...
 

Typedefs

template<std::size_t i, typename T >
using collection_element_t = typename collection_element< i, T >::type
 Helper template for collection_element.
 
template<typename T >
using common_collection_type_t = typename common_collection_type< T >::type
 Helper template for common_collection_type.
 

Functions

template<typename F , typename T , std::enable_if_t< collection< T > and values::fixed_value_compares_with< size_of< T >, stdex::dynamic_extent, &stdex::is_neq >, int > = 0>
decltype(auto) constexpr apply (F &&f, T &&t)
 A generalization of std::apply. More...
 
template<auto comp = &stdex::is_eq, typename Lhs , typename Rhs , std::enable_if_t< index< Lhs > and index< Rhs > and(sized< Lhs > or sized< Rhs >), int > = 0>
constexpr auto compare_indices (const Lhs &lhs, const Rhs &rhs)
 Performs an element-by-element comparison of two index collections. More...
 
template<typename Arg , typename I , std::enable_if_t< values::index< I > and(not values::size_compares_with< I, size_of< Arg >, &stdex::is_gteq >) and(stdex::ranges::random_access_range< Arg > or detail_get::has_member_get_function< Arg, I >::value or detail_get::has_adl_get_function< Arg, I >::value), int > = 0>
decltype(auto) constexpr get_element (Arg &&arg, I i)
 A generalization of std::get and the range subscript operator. 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< uniformly_gettable< 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< uniformly_gettable< Arg >, int > = 0>
constexpr auto tuple_reverse (Arg &&arg)
 Reverses the order of a uniformly_gettable object.
 
template<typename T , std::enable_if_t< uniformly_gettable< T > and stdex::default_initializable< 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<typename Lhs , typename Rhs , std::enable_if_t< collection< Lhs > and collection< Rhs > and(collection_view< Lhs > or collection_view< Rhs >) and(sized< Lhs > or sized< Rhs >), int > = 0>
constexpr stdex::partial_ordering lexicographical_compare_three_way (const Lhs &lhs, const Rhs &rhs)
 Compares two collections. More...
 
template<typename... Args>
 concat_tuple_view (Args &&...) -> concat_tuple_view< Args... >
 Deduction guide.
 
template<typename V >
 from_range (V &&) -> from_range< V >
 Deduction guide.
 
template<typename Tup >
 from_tuple_like (Tup &&) -> from_tuple_like< Tup >
 
template<typename F , typename S >
 generate_view (F, 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 Start >
 iota_view (const Start &) -> iota_view< Start >
 Deduction guide for an unsized iota.
 
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.
 

Variables

template<typename T >
constexpr bool collection
 An object describing a collection of objects. More...
 
template<typename T >
constexpr bool collection_view
 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 collections::get.
 
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
 A collection that can be modified on an element-by-element basis. More...
 
template<std::size_t i, typename C , typename T >
constexpr bool settable = detail::settable_impl<i, C, T>::value
 C has an element i that can be set by assigning the result of a get(...) function to an object of type T. More...
 
template<typename T >
constexpr bool tuple_like = 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 uniformly_gettable
 T is a fixed-size object that 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 viewable_tuple_like object that can be converted into a collection_view by passing it to collections::views::all. More...
 
template<typename T >
constexpr bool viewable_tuple_like
 A uniformly_gettable object that has a common_collection_type and can be converted into a collection_view by passing it to collections::views::all. More...
 
template<std::size_t i>
constexpr detail_get::get_impl< i > get
 A generalization of std::get, where the index is known at compile time. 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

◆ apply()

template<typename F , typename T , std::enable_if_t< collection< T > and values::fixed_value_compares_with< size_of< T >, stdex::dynamic_extent, &stdex::is_neq >, int > = 0>
decltype(auto) constexpr OpenKalman::collections::apply ( F &&  f,
T &&  t 
)

A generalization of std::apply.

This function takes a fixed-size collection and applies its elements as arguments of a function.

◆ compare_indices()

template<auto comp = &stdex::is_eq, typename Lhs , typename Rhs , std::enable_if_t< index< Lhs > and index< Rhs > and(sized< Lhs > or sized< Rhs >), int > = 0>
constexpr auto OpenKalman::collections::compare_indices ( const Lhs &  lhs,
const Rhs &  rhs 
)

Performs an element-by-element comparison of two index collections.

If one argument is longer than the other, the comparison will ignore the tail of the longer argument.

Template Parameters
compA callable object taking the comparison result (e.g., std::partial_ordering) and returning a bool value

◆ generate_view()

template<typename F >
OpenKalman::collections::generate_view ( ) -> 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_element()

template<typename Arg , typename I , std::enable_if_t< values::index< I > and(not values::size_compares_with< I, size_of< Arg >, &stdex::is_gteq >) and(stdex::ranges::random_access_range< Arg > or detail_get::has_member_get_function< Arg, I >::value or detail_get::has_adl_get_function< Arg, I >::value), int > = 0>
decltype(auto) constexpr OpenKalman::collections::get_element ( Arg &&  arg,
i 
)

A generalization of std::get and the range subscript operator.

This function works like std::get except that it works with any collection. The index can either be a template parameter constant or an argument. The function works as follows:

  • If index i is a template parameter constant and if the argument has a get<i*gt;() 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, if index i is either a template parameter constant or an argument, call std::ranges::begin(std::forward<Arg>(arg)) if it is a valid call.
    Note
    This function performs no runtime bounds checking.

◆ lexicographical_compare_three_way()

template<typename Lhs , typename Rhs , std::enable_if_t< collection< Lhs > and collection< Rhs > and(collection_view< Lhs > or collection_view< Rhs >) and(sized< Lhs > or sized< Rhs >), int > = 0>
constexpr stdex::partial_ordering OpenKalman::collections::lexicographical_compare_three_way ( const Lhs &  lhs,
const Rhs &  rhs 
)

Compares two collections.

This is the default case in which at least one of the arguments is a collection_view.

Variable Documentation

◆ collection

template<typename T >
constexpr bool OpenKalman::collections::collection
Initial value:
=
stdex::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.

◆ collection_view

template<typename T >
constexpr bool OpenKalman::collections::collection_view
Initial value:
=
collection<T> and
stdex::ranges::view<T>

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

◆ get

template<std::size_t i>
constexpr detail_get::get_impl<i> OpenKalman::collections::get
inline

A generalization of std::get, where the index is known at compile time.

Note
This function performs no runtime bounds checking.

◆ index

template<typename T >
constexpr bool OpenKalman::collections::index
Initial value:
=
collection<T> and
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45

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

Todo:
Change the definition to be values::index<collections::common_collection_type_t<T>>?

◆ invocable_on_collection

template<typename F , typename C , typename... Args>
constexpr bool OpenKalman::collections::invocable_on_collection
Initial value:
=
(not stdex::ranges::range<C> or detail::is_invocable_on_range<C, F, void, Args&&...>::value) and
(not uniformly_gettable<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 a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45

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

◆ output_collection

template<typename C , typename T >
constexpr bool OpenKalman::collections::output_collection
Initial value:
=
collection<C> and (stdex::ranges::output_range<C, T> or uniformly_settable<C, T>)

A collection that can be modified on an element-by-element basis.

◆ settable

template<std::size_t i, typename C , typename T >
constexpr bool OpenKalman::collections::settable = detail::settable_impl<i, C, T>::value

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.

◆ tuple_like

template<typename T >
constexpr bool OpenKalman::collections::tuple_like = 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
inline
Initial value:
=
sized<T> and
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45

T is a fixed-size object that is gettable for all indices.

◆ uniformly_settable

template<typename C , typename T >
constexpr bool OpenKalman::collections::uniformly_settable
Initial value:
=
((sized<C> and not values::fixed_value_compares_with<size_of<C>, stdex::dynamic_extent>) or settable<0_uz, C, T>) and
(not sized<C> or size_of_v<C> == stdex::dynamic_extent or
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45

C is settable with type C for all indices.

If C is not sized or has dynamic size, then it must be settable for at least index 0.

◆ viewable_collection

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

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

◆ viewable_tuple_like

template<typename T >
constexpr bool OpenKalman::collections::viewable_tuple_like
inline
Initial value:
=
uniformly_gettable<T> and
(std::is_lvalue_reference_v<T> or detail::has_viewable_elements<std::decay_t<T>>::value)
constexpr bool value
T is a fixed or dynamic value that is reducible to a number.
Definition: value.hpp:45
constexpr bool fixed_value_compares_with
T has a fixed value that compares with N in a particular way based on parameter comp.
Definition: fixed_value_compares_with.hpp:74

A uniformly_gettable object that has a common_collection_type and can be converted into a collection_view by passing it to collections::views::all.