Qx v0.7.2
Qt Extensions Library
Loading...
Searching...
No Matches
Qx::FixedList< T, N > Class Template Reference

The FixedList template class is a compile-time friendly fixed size container that wraps std::array, but provides an API that better matches Qt's sequential containers (e.g. QList). More...

#include <qx/core/qx-fixedlist.h>

Inheritance diagram for Qx::FixedList< T, N >:
[legend]

Public Types

using const_iterator = typename std::array<T, N>::const_iterator
 
using const_pointer = const T*
 
using const_reference = const T&
 
using const_reverse_iterator = typename std::array<T, N>::const_reverse_iterator
 
using ConstIterator = const_iterator
 
using difference_type = qsizetype
 
using Iterator = iterator
 
using iterator = typename std::array<T, N>::iterator
 
using parameter_type = const T&
 
using pointer = T*
 
using reference = T&
 
using reverse_iterator = typename std::array<T, N>::reverse_iterator
 
using size_type = qsizetype
 
using value_type = T
 

Public Member Functions

constexpr FixedList ()=default
 
template<typename A>
requires std::same_as<std::remove_cvref_t<A>, std::array<T, N>>
constexpr FixedList (A &&arr)
 
template<typename... Args>
requires (N > 0 && sizeof...(Args) == N && (std::convertible_to<Args, T> && ...))
constexpr FixedList (Args &&... args)
 
template<size_t M>
requires (M == N)
constexpr FixedList (const T(&arr)[M])
 
constexpr reference at (qsizetype i)
 
constexpr const_reference at (qsizetype i) const
 
constexpr reference back ()
 
constexpr const_reference back () const
 
constexpr const_iterator begin () const noexcept
 
constexpr iterator begin () noexcept
 
constexpr const_iterator cbegin () const noexcept
 
constexpr const_iterator cend () const noexcept
 
template<qsizetype K>
constexpr auto chopped () const
 
constexpr const_iterator constBegin () const noexcept
 
constexpr const_pointer constData () const noexcept
 
constexpr const_iterator constEnd () const noexcept
 
constexpr const_reference constFirst () const
 
constexpr const_reference constLast () const
 
template<typename AT = T>
constexpr bool contains (const AT &t) const
 
template<typename AT = T>
constexpr qsizetype count (const AT &t) const
 
constexpr const_reverse_iterator crbegin () const noexcept
 
constexpr const_reverse_iterator crend () const noexcept
 
constexpr const_pointer data () const noexcept
 
constexpr pointer data () noexcept
 
constexpr const_iterator end () const noexcept
 
constexpr iterator end () noexcept
 
template<typename AT = T>
constexpr bool endsWith (const AT &t) const
 
template<typename AT = T>
constexpr FixedList & fill (const AT &t)
 
constexpr reference first ()
 
constexpr const_reference first () const
 
template<qsizetype K>
constexpr auto first () const
 
constexpr reference front ()
 
constexpr const_reference front () const
 
template<size_t I>
constexpr T && get () &&noexcept
 
template<size_t I>
constexpr T & get () &noexcept
 
template<size_t I>
constexpr const T & get () const &noexcept
 
template<typename AT = T>
constexpr qsizetype indexOf (const AT &t, qsizetype from=0) const
 
constexpr reference last ()
 
constexpr const_reference last () const
 
template<qsizetype K>
constexpr auto last () const
 
template<typename AT = T>
constexpr qsizetype lastIndexOf (const AT &t, qsizetype from=-1) const
 
template<qsizetype Pos, qsizetype Len = -1>
constexpr auto mid () const
 
constexpr void move (qsizetype from, qsizetype to)
 
template<size_t M>
constexpr FixedList< T, N+M > operator+ (const FixedList< T, M > &other) const
 
constexpr FixedList< T, N+1 > operator+ (const T &other) const
 
template<size_t M>
constexpr FixedList< T, N+M > operator+ (const T(&other)[M]) const
 
constexpr auto operator<=> (const FixedList &other) const =default
 
constexpr bool operator== (const FixedList &other) const =default
 
constexpr reference operator[] (qsizetype i)
 
constexpr const_reference operator[] (qsizetype i) const
 
constexpr const_reverse_iterator rbegin () const noexcept
 
constexpr reverse_iterator rbegin () noexcept
 
constexpr const_reverse_iterator rend () const noexcept
 
constexpr reverse_iterator rend () noexcept
 
template<typename AT = T>
constexpr void replace (qsizetype i, const AT &t)
 
template<qsizetype Pos, qsizetype K>
constexpr auto sliced () const
 
template<qsizetype Pos>
constexpr auto sliced () const
 
template<typename AT = T>
constexpr bool startsWith (const AT &t) const
 
constexpr const std::array< T, N > & stdArray () const noexcept
 
constexpr std::array< T, N > & stdArray () noexcept
 
constexpr void swap (FixedList &other) noexcept(std::is_nothrow_swappable_v< T >)
 
constexpr void swapItemsAt (qsizetype i, qsizetype j)
 
QList< T > toList () const
 
constexpr std::array< T, N > toStdArray () const
 
constexpr T value (qsizetype i) const
 
template<typename AT = T>
constexpr T value (qsizetype i, const AT &defaultValue) const
 

Static Public Member Functions

static constexpr qsizetype count () noexcept
 
static constexpr bool empty () noexcept
 
static constexpr bool isEmpty () noexcept
 
static constexpr qsizetype length () noexcept
 
static constexpr qsizetype size () noexcept
 

Static Public Attributes

static constexpr qsizetype size_v = static_cast<qsizetype>(N)
 

Friends

size_t qHash (const FixedList &key, size_t seed=0)
 
constexpr void swap (FixedList &a, FixedList &b) noexcept(noexcept(a.swap(b)))
 

Related Symbols

(Note that these are not member symbols.)

template<typename T, size_t N>
constexpr FixedList< T, N > makeFixedList (const T(&arr)[N])
 
template<typename T, size_t N>
constexpr FixedList< T, 1+N > operator+ (const std::type_identity_t< T > &a, const FixedList< T, N > &b)
 
template<typename T, size_t M, size_t N>
constexpr FixedList< T, M+N > operator+ (const T(&a)[M], const FixedList< T, N > &b)
 

Detailed Description

template<typename T, size_t N>
class Qx::FixedList< T, N >

The underlying iterators are those of std::array, so a FixedList can be used with all of the standard algorithms (i.e. std::sort(), std::ranges::reverse(), etc.), many of which are usable in constant expressions.

Both the element type and size can be deduced when constructing from a C array or from a series of elements:.

Qx::FixedList fl1{{3, 6, 10}}; // FixedList<int, 3>
Qx::FixedList fl2{3, 6, 10}; // FixedList<int, 3>
Qx::FixedList<int, 3> fl3{{3, 6, 10}};
auto fl4 = Qx::makeFixedList<double>({3, 6, 10}); // FixedList<double, 3>
auto fl5 = fl1 + fl3.sliced<1, 2>(); // FixedList<int, 5>
The FixedList template class is a compile-time friendly fixed size container that wraps std::array,...
Definition qx-fixedlist.h:44
constexpr FixedList< T, N > makeFixedList(const T(&arr)[N])
Definition qx-fixedlist.h:464
constexpr auto sliced() const
Definition qx-fixedlist.h:348
Note
It isn't possible to specify only the element type and have the size be deduced when constructing with CTAD (i.e. FixedList<int>{{1,2,3}}). Use makeFixedList() if you wish to explicitly specify the element type but still have the size deduced.

A FixedList can also be used with structured bindings.

Qx::FixedList fl{3, 6, 10};
auto [a, b, c] = fl;
See also
makeFixedList()

Member Typedef Documentation

◆ const_iterator

template<typename T, size_t N>
using Qx::FixedList< T, N >::const_iterator = typename std::array<T, N>::const_iterator

The type of the const STL-style iterators. This is the same as the const iterator type of the underlying std::array.

See also
cbegin(), cend()

◆ const_pointer

template<typename T, size_t N>
using Qx::FixedList< T, N >::const_pointer = const T*

A pointer to a constant item in the list (const T*).

◆ const_reference

template<typename T, size_t N>
using Qx::FixedList< T, N >::const_reference = const T&

A reference to a constant item in the list (const T&).

◆ const_reverse_iterator

template<typename T, size_t N>
using Qx::FixedList< T, N >::const_reverse_iterator = typename std::array<T, N>::const_reverse_iterator

The type of the const STL-style reverse iterators.

See also
crbegin(), crend()

◆ ConstIterator

template<typename T, size_t N>
using Qx::FixedList< T, N >::ConstIterator = const_iterator

Qt-style synonym for FixedList::const_iterator.

◆ difference_type

template<typename T, size_t N>
using Qx::FixedList< T, N >::difference_type = qsizetype

The type used for the difference between positions in the list (qsizetype).

◆ Iterator

template<typename T, size_t N>
using Qx::FixedList< T, N >::Iterator = iterator

Qt-style synonym for FixedList::iterator.

◆ iterator

template<typename T, size_t N>
using Qx::FixedList< T, N >::iterator = typename std::array<T, N>::iterator

The type of the non-const STL-style iterators. This is the same as the iterator type of the underlying std::array.

See also
begin(), end()

◆ parameter_type

template<typename T, size_t N>
using Qx::FixedList< T, N >::parameter_type = const T&

The type used when passing an item to a function (const T&).

◆ pointer

template<typename T, size_t N>
using Qx::FixedList< T, N >::pointer = T*

A pointer to an item in the list (T*).

◆ reference

template<typename T, size_t N>
using Qx::FixedList< T, N >::reference = T&

A reference to an item in the list (T&).

◆ reverse_iterator

template<typename T, size_t N>
using Qx::FixedList< T, N >::reverse_iterator = typename std::array<T, N>::reverse_iterator

The type of the non-const STL-style reverse iterators.

See also
rbegin(), rend()

◆ size_type

template<typename T, size_t N>
using Qx::FixedList< T, N >::size_type = qsizetype

The type used for sizes and counts (qsizetype).

◆ value_type

template<typename T, size_t N>
using Qx::FixedList< T, N >::value_type = T

The type of the items stored in the list (T).

Constructor & Destructor Documentation

◆ FixedList() [1/4]

template<typename T, size_t N>
Qx::FixedList< T, N >::FixedList ( )
constexprdefault

Constructs an empty list.

◆ FixedList() [2/4]

template<typename T, size_t N>
template<size_t M>
requires (M == N)
Qx::FixedList< T, N >::FixedList ( const T(&) arr[M])
inlineconstexpr

Constructs a list that contains copies of the items in the C array arr.

Requires that M is equal to N.

◆ FixedList() [3/4]

template<typename T, size_t N>
template<typename A>
requires std::same_as<std::remove_cvref_t<A>, std::array<T, N>>
Qx::FixedList< T, N >::FixedList ( A && arr)
inlineconstexpr

Constructs a list that contains the items in the std::array arr, which are copied or moved depending on the value category of arr.

Requires that A is a (possibly cv-qualified/reference) std::array<T, N>.

◆ FixedList() [4/4]

template<typename T, size_t N>
template<typename... Args>
requires (N > 0 && sizeof...(Args) == N && (std::convertible_to<Args, T> && ...))
Qx::FixedList< T, N >::FixedList ( Args &&... args)
inlineconstexpr

Constructs a list from the items in args, each of which must be convertible to T.

Requires that the number of arguments is equal to N, and that N is greater than zero. This constructor is explicit if N is 1.

Member Function Documentation

◆ at() [1/2]

template<typename T, size_t N>
reference Qx::FixedList< T, N >::at ( qsizetype i)
inlineconstexpr

Returns the item at index position i as a modifiable reference.

i must be a valid index position in the list (i.e., 0 <= i < size()).

See also
value(), operator[]()

◆ at() [2/2]

template<typename T, size_t N>
const_reference Qx::FixedList< T, N >::at ( qsizetype i) const
inlineconstexpr

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

◆ back() [1/2]

template<typename T, size_t N>
reference Qx::FixedList< T, N >::back ( )
inlineconstexpr

This function is provided for STL compatibility. It is equivalent to last().

◆ back() [2/2]

template<typename T, size_t N>
const_reference Qx::FixedList< T, N >::back ( ) const
inlineconstexpr

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

◆ begin() [1/2]

template<typename T, size_t N>
const_iterator Qx::FixedList< T, N >::begin ( ) const
inlineconstexprnoexcept

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

◆ begin() [2/2]

template<typename T, size_t N>
iterator Qx::FixedList< T, N >::begin ( )
inlineconstexprnoexcept

Returns an STL-style iterator pointing to the first item in the list.

See also
constBegin(), end()

◆ cbegin()

template<typename T, size_t N>
const_iterator Qx::FixedList< T, N >::cbegin ( ) const
inlineconstexprnoexcept

Returns a const STL-style iterator pointing to the first item in the list.

See also
begin(), cend()

◆ cend()

template<typename T, size_t N>
const_iterator Qx::FixedList< T, N >::cend ( ) const
inlineconstexprnoexcept

Returns a const STL-style iterator pointing to the imaginary item after the last item in the list.

See also
end(), cbegin()

◆ chopped()

template<typename T, size_t N>
template<qsizetype K>
auto Qx::FixedList< T, N >::chopped ( ) const
inlineconstexpr

Returns a FixedList<T, N - K> that contains copies of all but the last K items in this list.

K must be non-negative and no greater than N.

See also
first(), sliced(), mid()

◆ constBegin()

template<typename T, size_t N>
const_iterator Qx::FixedList< T, N >::constBegin ( ) const
inlineconstexprnoexcept

Returns a const STL-style iterator pointing to the first item in the list.

See also
begin(), constEnd()

◆ constData()

template<typename T, size_t N>
const_pointer Qx::FixedList< T, N >::constData ( ) const
inlineconstexprnoexcept

Returns a const pointer to the data stored in the list.

See also
data()

◆ constEnd()

template<typename T, size_t N>
const_iterator Qx::FixedList< T, N >::constEnd ( ) const
inlineconstexprnoexcept

Returns a const STL-style iterator pointing to the imaginary item after the last item in the list.

See also
end(), constBegin()

◆ constFirst()

template<typename T, size_t N>
const_reference Qx::FixedList< T, N >::constFirst ( ) const
inlineconstexpr

Returns a const reference to the first item in the list.

Requires the list to not be empty.

See also
first(), constLast(), isEmpty()

◆ constLast()

template<typename T, size_t N>
const_reference Qx::FixedList< T, N >::constLast ( ) const
inlineconstexpr

Returns a const reference to the last item in the list.

Requires the list to not be empty.

See also
last(), constFirst(), isEmpty()

◆ contains()

template<typename T, size_t N>
template<typename AT = T>
bool Qx::FixedList< T, N >::contains ( const AT & t) const
inlineconstexpr

Returns true if the list contains an item equal to t; otherwise, returns false.

This function requires AT to be comparable with T via operator==().

See also
indexOf(), count(const AT&)

◆ count() [1/2]

template<typename T, size_t N>
static constexpr qsizetype Qx::FixedList< T, N >::count ( )
inlinestaticconstexprnoexcept

Returns the number of items in the list.

This is the same as size_v, count() and length().

See also
isEmpty()
count(const AT&)

◆ count() [2/2]

template<typename T, size_t N>
template<typename AT = T>
qsizetype Qx::FixedList< T, N >::count ( const AT & t) const
inlineconstexpr

Returns the number of items in the list that are equal to t.

This function requires AT to be comparable with T via operator==().

See also
contains(), indexOf()

◆ crbegin()

template<typename T, size_t N>
const_reverse_iterator Qx::FixedList< T, N >::crbegin ( ) const
inlineconstexprnoexcept

Returns a const STL-style reverse iterator pointing to the first item in the reversed list (i.e., the last item in the list).

See also
rbegin(), crend()

◆ crend()

template<typename T, size_t N>
const_reverse_iterator Qx::FixedList< T, N >::crend ( ) const
inlineconstexprnoexcept

Returns a const STL-style reverse iterator pointing to the imaginary item after the last item in the reversed list (i.e., the imaginary item before the first item in the list).

See also
rend(), crbegin()

◆ data() [1/2]

template<typename T, size_t N>
const_pointer Qx::FixedList< T, N >::data ( ) const
inlineconstexprnoexcept

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

◆ data() [2/2]

template<typename T, size_t N>
pointer Qx::FixedList< T, N >::data ( )
inlineconstexprnoexcept

Returns a pointer to the data stored in the list. The pointer can be used to access and modify the items in the list.

The pointer remains valid for as long as the list exists.

See also
constData(), operator[]()

◆ empty()

template<typename T, size_t N>
static constexpr bool Qx::FixedList< T, N >::empty ( )
inlinestaticconstexprnoexcept

This function is provided for STL compatibility. It is equivalent to isEmpty().

◆ end() [1/2]

template<typename T, size_t N>
const_iterator Qx::FixedList< T, N >::end ( ) const
inlineconstexprnoexcept

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

◆ end() [2/2]

template<typename T, size_t N>
iterator Qx::FixedList< T, N >::end ( )
inlineconstexprnoexcept

Returns an STL-style iterator pointing to the imaginary item after the last item in the list.

See also
constEnd(), begin()

◆ endsWith()

template<typename T, size_t N>
template<typename AT = T>
bool Qx::FixedList< T, N >::endsWith ( const AT & t) const
inlineconstexpr

Returns true if the list is not empty and its last item is equal to t; otherwise, returns false.

This function requires AT to be comparable with T via operator==().

See also
startsWith(), last()

◆ fill()

template<typename T, size_t N>
template<typename AT = T>
FixedList & Qx::FixedList< T, N >::fill ( const AT & t)
inlineconstexpr

Assigns t to all items in the list. Returns a reference to the list.

This function requires T to be assignable from AT.

◆ first() [1/3]

template<typename T, size_t N>
reference Qx::FixedList< T, N >::first ( )
inlineconstexpr

Returns a reference to the first item in the list.

Requires the list to not be empty.

See also
constFirst(), last(), isEmpty()

◆ first() [2/3]

template<typename T, size_t N>
const_reference Qx::FixedList< T, N >::first ( ) const
inlineconstexpr

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

◆ first() [3/3]

template<typename T, size_t N>
template<qsizetype K>
auto Qx::FixedList< T, N >::first ( ) const
inlineconstexpr

Returns a FixedList<T, K> that contains copies of the first K items in this list.

K must be non-negative and no greater than N.

See also
last(), sliced(), chopped(), mid()

◆ front() [1/2]

template<typename T, size_t N>
reference Qx::FixedList< T, N >::front ( )
inlineconstexpr

This function is provided for STL compatibility. It is equivalent to first().

◆ front() [2/2]

template<typename T, size_t N>
const_reference Qx::FixedList< T, N >::front ( ) const
inlineconstexpr

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

◆ get() [1/3]

template<typename T, size_t N>
template<size_t I>
T && Qx::FixedList< T, N >::get ( ) &&
inlineconstexprnoexcept

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

◆ get() [2/3]

template<typename T, size_t N>
template<size_t I>
T & Qx::FixedList< T, N >::get ( ) &
inlineconstexprnoexcept

Returns a reference to the item at index I.

This function exists to provide support for structured bindings. I must be less than N.

◆ get() [3/3]

template<typename T, size_t N>
template<size_t I>
const T & Qx::FixedList< T, N >::get ( ) const &
inlineconstexprnoexcept

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

◆ indexOf()

template<typename T, size_t N>
template<typename AT = T>
qsizetype Qx::FixedList< T, N >::indexOf ( const AT & t,
qsizetype from = 0 ) const
inlineconstexpr

Returns the index position of the first occurrence of t in the list, searching forward from index position from. Returns -1 if no item matched.

If from is negative, it is interpreted as an offset from the end of the list (i.e. -1 starts the search at the last item).

This function requires AT to be comparable with T via operator==().

See also
lastIndexOf(), contains()

◆ isEmpty()

template<typename T, size_t N>
static constexpr bool Qx::FixedList< T, N >::isEmpty ( )
inlinestaticconstexprnoexcept

Returns true if the list has a size of 0; otherwise, returns false.

See also
size()

◆ last() [1/3]

template<typename T, size_t N>
reference Qx::FixedList< T, N >::last ( )
inlineconstexpr

Returns a reference to the last item in the list.

Requires the list to not be empty.

See also
constLast(), first(), isEmpty()

◆ last() [2/3]

template<typename T, size_t N>
const_reference Qx::FixedList< T, N >::last ( ) const
inlineconstexpr

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

◆ last() [3/3]

template<typename T, size_t N>
template<qsizetype K>
auto Qx::FixedList< T, N >::last ( ) const
inlineconstexpr

Returns a FixedList<T, K> that contains copies of the last K items in this list.

K must be non-negative and no greater than N.

See also
first(), sliced(), chopped(), mid()

◆ lastIndexOf()

template<typename T, size_t N>
template<typename AT = T>
qsizetype Qx::FixedList< T, N >::lastIndexOf ( const AT & t,
qsizetype from = -1 ) const
inlineconstexpr

Returns the index position of the last occurrence of t in the list, searching backward from index position from. Returns -1 if no item matched.

If from is negative, it is interpreted as an offset from the end of the list (i.e. -1, the default, starts the search at the last item). If from is greater than or equal to the size of the list, the search starts at the last item.

This function requires AT to be comparable with T via operator==().

See also
indexOf(), contains()

◆ length()

template<typename T, size_t N>
static constexpr qsizetype Qx::FixedList< T, N >::length ( )
inlinestaticconstexprnoexcept

Returns the number of items in the list.

This is the same as size_v, count() and length().

See also
isEmpty()

◆ mid()

template<typename T, size_t N>
template<qsizetype Pos, qsizetype Len = -1>
auto Qx::FixedList< T, N >::mid ( ) const
inlineconstexpr

Returns a FixedList that contains copies of up to Len items in this list, starting at index position Pos.

If Len is negative (the default) or would extend past the end of the list, all items from Pos to the end are returned. The size of the result is therefore min(Len, N - Pos), or N - Pos if Len is negative.

Unlike QList::mid(), Pos must be non-negative and no greater than N, as an out-of-range position would otherwise need to produce a differently sized list at run-time.

See also
first(), last(), sliced(), chopped()

◆ move()

template<typename T, size_t N>
void Qx::FixedList< T, N >::move ( qsizetype from,
qsizetype to )
inlineconstexpr

Moves the item at index position from to index position to, shifting the items in between accordingly.

Both from and to must be valid index positions in the list (i.e., 0 <= from, to < size()).

See also
swapItemsAt()

◆ operator+() [1/3]

template<typename T, size_t N>
template<size_t M>
FixedList< T, N+M > Qx::FixedList< T, N >::operator+ ( const FixedList< T, M > & other) const
inlineconstexpr

Returns a FixedList of size N + M that contains all the items in this list followed by all the items in other.

See also
operator+(const T (&other)[M]) const, operator+(const T& other) const

◆ operator+() [2/3]

template<typename T, size_t N>
FixedList< T, N+1 > Qx::FixedList< T, N >::operator+ ( const T & other) const
inlineconstexpr

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

Returns a FixedList of size N + 1 that contains all the items in this list followed by other.

◆ operator+() [3/3]

template<typename T, size_t N>
template<size_t M>
FixedList< T, N+M > Qx::FixedList< T, N >::operator+ ( const T(&) other[M]) const
inlineconstexpr

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

Returns a FixedList of size N + M that contains all the items in this list followed by all the items in the C array other.

◆ operator<=>()

template<typename T, size_t N>
auto Qx::FixedList< T, N >::operator<=> ( const FixedList< T, N > & other) const
constexprdefault

Returns the ordering of other relative to this.

Items are compared lexicographically. This operator is only available if T supports three-way comparison or operator<(); otherwise it is deleted.

◆ operator==()

template<typename T, size_t N>
bool Qx::FixedList< T, N >::operator== ( const FixedList< T, N > & other) const
constexprdefault

Returns true if the FixedList is equal to other; otherwise, returns false.

Two lists are equal if each of their items compare equal, in order. Lists of different sizes or different element types are different types and cannot be compared.

operator!=() is synthesized from this operator.

◆ operator[]() [1/2]

template<typename T, size_t N>
reference Qx::FixedList< T, N >::operator[] ( qsizetype i)
inlineconstexpr

Returns the item at index position i as a modifiable reference.

i must be a valid index position in the list (i.e., 0 <= i < size()).

See also
at(), value()

◆ operator[]() [2/2]

template<typename T, size_t N>
const_reference Qx::FixedList< T, N >::operator[] ( qsizetype i) const
inlineconstexpr

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

◆ rbegin() [1/2]

template<typename T, size_t N>
const_reverse_iterator Qx::FixedList< T, N >::rbegin ( ) const
inlineconstexprnoexcept

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

◆ rbegin() [2/2]

template<typename T, size_t N>
reverse_iterator Qx::FixedList< T, N >::rbegin ( )
inlineconstexprnoexcept

Returns an STL-style reverse iterator pointing to the first item in the reversed list (i.e., the last item in the list).

See also
crbegin(), rend()

◆ rend() [1/2]

template<typename T, size_t N>
const_reverse_iterator Qx::FixedList< T, N >::rend ( ) const
inlineconstexprnoexcept

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

◆ rend() [2/2]

template<typename T, size_t N>
reverse_iterator Qx::FixedList< T, N >::rend ( )
inlineconstexprnoexcept

Returns an STL-style reverse iterator pointing to the imaginary item after the last item in the reversed list (i.e., the imaginary item before the first item in the list).

See also
crend(), rbegin()

◆ replace()

template<typename T, size_t N>
template<typename AT = T>
void Qx::FixedList< T, N >::replace ( qsizetype i,
const AT & t )
inlineconstexpr

Replaces the item at index position i with t.

i must be a valid index position in the list (i.e., 0 <= i < size()).

This function requires T to be assignable from AT.

See also
operator[](), at()

◆ size()

template<typename T, size_t N>
static constexpr qsizetype Qx::FixedList< T, N >::size ( )
inlinestaticconstexprnoexcept

Returns the number of items in the list.

This is the same as size_v, count() and length().

See also
isEmpty()

◆ sliced() [1/2]

template<typename T, size_t N>
template<qsizetype Pos, qsizetype K>
auto Qx::FixedList< T, N >::sliced ( ) const
inlineconstexpr

Returns a FixedList<T, K> that contains copies of K items in this list, starting at index position Pos.

Pos and K must be non-negative and Pos + K must be no greater than N.

See also
first(), last(), chopped(), mid()

◆ sliced() [2/2]

template<typename T, size_t N>
template<qsizetype Pos>
auto Qx::FixedList< T, N >::sliced ( ) const
inlineconstexpr

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

Returns a FixedList<T, N - Pos> that contains copies of all items in this list from index position Pos to the end.

Pos must be non-negative and no greater than N.

◆ startsWith()

template<typename T, size_t N>
template<typename AT = T>
bool Qx::FixedList< T, N >::startsWith ( const AT & t) const
inlineconstexpr

Returns true if the list is not empty and its first item is equal to t; otherwise, returns false.

This function requires AT to be comparable with T via operator==().

See also
endsWith(), first()

◆ stdArray() [1/2]

template<typename T, size_t N>
const std::array< T, N > & Qx::FixedList< T, N >::stdArray ( ) const
inlineconstexprnoexcept

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

◆ stdArray() [2/2]

template<typename T, size_t N>
std::array< T, N > & Qx::FixedList< T, N >::stdArray ( )
inlineconstexprnoexcept

Returns a reference to the underlying std::array.

See also
toStdArray()

◆ swap()

template<typename T, size_t N>
void Qx::FixedList< T, N >::swap ( FixedList< T, N > & other)
inlineconstexprnoexcept

Swaps the contents of this list with other.

See also
swapItemsAt()

◆ swapItemsAt()

template<typename T, size_t N>
void Qx::FixedList< T, N >::swapItemsAt ( qsizetype i,
qsizetype j )
inlineconstexpr

Exchanges the item at index position i with the item at index position j.

Both i and j must be valid index positions in the list (i.e., 0 <= i, j < size()).

See also
swap()

◆ toList()

template<typename T, size_t N>
QList< T > Qx::FixedList< T, N >::toList ( ) const
inline

Returns a QList that contains copies of the items in this list.

◆ toStdArray()

template<typename T, size_t N>
std::array< T, N > Qx::FixedList< T, N >::toStdArray ( ) const
inlineconstexpr

Returns a copy of the underlying std::array.

See also
stdArray()

◆ value() [1/2]

template<typename T, size_t N>
T Qx::FixedList< T, N >::value ( qsizetype i) const
inlineconstexpr

Returns the item at index position i in the list. If i is out of bounds, the function returns a default-constructed value.

Requires T to be default-initializable.

See also
at(), operator[]()

◆ value() [2/2]

template<typename T, size_t N>
template<typename AT = T>
T Qx::FixedList< T, N >::value ( qsizetype i,
const AT & defaultValue ) const
inlineconstexpr

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

If i is out of bounds, the function returns defaultValue converted to T.

Friends And Related Symbol Documentation

◆ makeFixedList()

template<typename T, size_t N>
FixedList< T, N > makeFixedList ( const T(&) arr[N])
related

Creates a FixedList from a C array or braced list, deducing the size. The element type can be explicitly specified when the deduced one isn't wanted, i.e. makeFixedList<double>({1, 2, 3}).

◆ operator+() [1/2]

template<typename T, size_t N>
FixedList< T, 1+N > operator+ ( const std::type_identity_t< T > & a,
const FixedList< T, N > & b )
related

Returns a FixedList which is the result of concatenating a and b.

◆ operator+() [2/2]

template<typename T, size_t M, size_t N>
FixedList< T, M+N > operator+ ( const T(&) a[M],
const FixedList< T, N > & b )
related

Returns a FixedList which is the result of concatenating a and b.

◆ qHash

template<typename T, size_t N>
size_t qHash ( const FixedList< T, N > & key,
size_t seed = 0 )
friend

Returns the hash value for key, using seed to seed the calculation.

This function requires T to be hashable via qHash().

◆ swap

template<typename T, size_t N>
void swap ( FixedList< T, N > & a,
FixedList< T, N > & b )
friend

Swaps the contents of a and b.

See also
FixedList::swap()

Member Data Documentation

◆ size_v

template<typename T, size_t N>
qsizetype Qx::FixedList< T, N >::size_v = static_cast<qsizetype>(N)
staticconstexpr

The number of items in the list.

For ease of use in some contexts at compile-time.


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