### Boost.Array Data Access Source: https://www.boost.org/doc/libs/latest/libs/array/index Provides methods to get a pointer to the underlying C-style array data. `data()` returns a pointer to the beginning of the `elems` array and is `constexpr` and `noexcept`. The deprecated `c_array()` method also returns this pointer. ```cpp constexpr T* data() noexcept; constexpr const T* data() const noexcept; T* c_array() noexcept; // deprecated ``` -------------------------------- ### Boost.Array Namespace Declarations (C++) Source: https://www.boost.org/doc/libs/latest/libs/array/index This snippet shows the core declarations within the `boost` namespace for the `array` class template and related functions. It includes template class `array`, free functions like `swap`, comparison operators (`==`, `!=`, `<`, `>`, `<=`, `>=`), the spaceship operator (`<=>`), and helper functions like `get` and `to_array`. These define the interface for fixed-size arrays provided by Boost.Array. ```cpp namespace boost { template class array; template void swap(array&, array&); template constexpr bool operator==(const array&, const array&); template constexpr bool operator!=(const array&, const array&); template constexpr bool operator<(const array&, const array&); template constexpr bool operator>(const array&, const array&); template constexpr bool operator<=(const array&, const array&); template constexpr bool operator>=(const array&, const array&); template constexpr auto operator<=>(const array&, const array&); template constexpr T& get(array&) noexcept; template constexpr const T& get(const array&) noexcept; template constexpr array to_array( T const (&)[N] ); template constexpr array to_array( T (&&)[N] ); template constexpr array to_array( T const (&&)[N] ); } ``` -------------------------------- ### Get element by index from array in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/index Tuple-like access function to retrieve an element at compile-time-known index from an array. Provides both mutable and const versions. Mandates that the index must be less than N. Declared noexcept. ```cpp template constexpr T& get(array& arr) noexcept; template constexpr const T& get(const array& arr) noexcept; ``` -------------------------------- ### Access Array Elements by Index in Boost Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Provides constexpr tuple-like get() function for accessing array elements by compile-time index. Returns reference to element at position Idx and is marked noexcept for non-throwing element access. ```cpp template constexpr T& get(array&) noexcept; template constexpr const T& get(const array&) noexcept; ``` -------------------------------- ### Boost.Array Reference Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array This section details the header and the `boost::array` class template, including its constructors, comparison operators, and utility functions. ```APIDOC ## Header This header provides the `boost::array` class template and associated functions. ### Namespace `boost` ```cpp namespace boost { template class array; template void swap(array&, array&); template constexpr bool operator==(const array&, const array&); template constexpr bool operator!=(const array&, const array&); template constexpr bool operator<(const array&, const array&); template constexpr bool operator>(const array&, const array&); template constexpr bool operator<=(const array&, const array&); template constexpr bool operator>=(const array&, const array&); template constexpr auto operator<=>(const array&, const array&); template constexpr T& get(array&) noexcept; template constexpr const T& get(const array&) noexcept; template constexpr array to_array( T const (&)[N] ); template constexpr array to_array( T (&&)[N] ); template constexpr array to_array( T const (&&)[N] ); } ``` ``` -------------------------------- ### Aggregate initialization for boost::array in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Demonstrates aggregate initialization for `boost::array`, allowing initialization with a brace-enclosed list of elements. If fewer initializers are provided than elements, remaining elements are default-initialized. ```cpp boost::array a = { { 1, 2, 3 } }; // Note: If there are fewer elements in the initializer list, then each remaining element gets default-initialized. ``` ```cpp boost::array a = { 1, 2, 3 }; // According to C++ Standard 8.5.1 (11), fewer braces can be used for initialization. ``` -------------------------------- ### Class template array Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Detailed documentation for the `boost::array` class template, outlining its properties, member functions, and behavior in relation to STL container requirements. ```APIDOC ## Class template `array` The `boost::array` class template provides a fixed-size array container that mimics the interface of STL containers. ### Properties * **Static Size**: The size of the array is determined at compile time and cannot be changed. * **STL Compatibility**: Implements many requirements of "reversible containers" and "sequences" from the C++ Standard Library, with some noted exceptions. ### Member Functions * **Constructors**: No constructors are provided for `boost::array`. * **Element Access**: Provides `operator[]`, `at()`, `front()`, and `back()` for accessing elements. * **Iterators**: Provides iterators compatible with STL. * **Size**: `size()` returns the constant size of the array. ### Design Rationale & Behavior * Elements may have an undetermined initial value. * `swap()` does not have constant complexity. * The container does not provide allocator support. ### Comparison with `std::array` `boost::array` is largely compatible with `std::array` (available since C++11). If using C++11 or later, `std::array` is recommended. ### Revision History Highlights (1.88.0) * `noexcept` and `constexpr` added where appropriate. * `array` behavior modified to match `std::array`, returning `nullptr` for iterators and enabling `constexpr`. * `array` can now be initialized with `= {{}}`. * `operator<=>` added. * `to_array` utility function added. ``` -------------------------------- ### Boost.Array Capacity Methods Source: https://www.boost.org/doc/libs/latest/libs/array/index Static methods for querying the capacity of a `boost::array`. `size()` and `max_size()` return the fixed size `N`, while `empty()` returns `true` if `N` is 0. These methods are `static constexpr` and `noexcept`. ```cpp static constexpr size_type size() noexcept; static constexpr bool empty() noexcept; static constexpr size_type max_size() noexcept; ``` -------------------------------- ### Boost Array Class Overview Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Provides an overview of the boost::array class template, its type definitions, static constants, and member functions for managing fixed-size arrays. ```APIDOC ## Class: boost::array ### Description Represents a fixed-size array container with elements of type `T` and size `N`. It offers C++ standard library-like interface for array manipulation. ### Types - `value_type`: The type of elements stored in the array. - `iterator`: A random access iterator to the elements. - `const_iterator`: A constant random access iterator to the elements. - `reverse_iterator`: A reverse iterator. - `const_reverse_iterator`: A constant reverse iterator. - `reference`: A reference to an element. - `const_reference`: A constant reference to an element. - `size_type`: An unsigned integral type for sizes. - `difference_type`: A signed integral type for difference between iterators. ### Static Constants - `static const size_type static_size = N;`: The fixed size of the array. ### Member Functions - **Construct/Copy/Destroy** - `template array& operator=(const array& other);`: Assigns contents of another array. - **Iterator Support** - `constexpr iterator begin() noexcept;`: Returns an iterator to the beginning. - `constexpr const_iterator begin() const noexcept;`: Returns a constant iterator to the beginning. - `constexpr const_iterator cbegin() const noexcept;`: Returns a constant iterator to the beginning. - `constexpr iterator end() noexcept;`: Returns an iterator to the end. - `constexpr const_iterator end() const noexcept;`: Returns a constant iterator to the end. - `constexpr const_iterator cend() const noexcept;`: Returns a constant iterator to the end. - **Reverse Iterator Support** - `reverse_iterator rbegin() noexcept;`: Returns a reverse iterator to the beginning. - `const_reverse_iterator rbegin() const noexcept;`: Returns a constant reverse iterator to the beginning. - `const_reverse_iterator crbegin() const noexcept;`: Returns a constant reverse iterator to the beginning. - `reverse_iterator rend() noexcept;`: Returns a reverse iterator to the end. - `const_reverse_iterator rend() const noexcept;`: Returns a constant reverse iterator to the end. - `const_reverse_iterator crend() const noexcept;`: Returns a constant reverse iterator to the end. - **Capacity** - `static constexpr size_type size() noexcept;`: Returns the size of the array (N). - `static constexpr bool empty() noexcept;`: Checks if the array is empty (N == 0). - `static constexpr size_type max_size() noexcept;`: Returns the maximum size of the array (N). - **Element Access** - `constexpr reference operator[](size_type i);`: Accesses element at index `i` (no bounds checking). - `constexpr const_reference operator[](size_type i) const;`: Accesses element at index `i` (no bounds checking). - `constexpr reference at(size_type i);`: Accesses element at index `i` with bounds checking. - `constexpr const_reference at(size_type i) const;`: Accesses element at index `i` with bounds checking. - `constexpr reference front();`: Accesses the first element. - `constexpr const_reference front() const;`: Accesses the first element (const). - `constexpr reference back();`: Accesses the last element. - `constexpr const_reference back() const;`: Accesses the last element (const). - `constexpr T* data() noexcept;`: Returns a pointer to the underlying C-style array. - `constexpr const T* data() const noexcept;`: Returns a constant pointer to the underlying C-style array. - `T* c_array() noexcept; // deprecated`: Returns a pointer to the underlying C-style array (deprecated). - **Modifiers** - `swap(array& other);`: Swaps contents with another array. - `constexpr void fill(const T& value);`: Assigns a value to all elements. - `void assign(const T& value); // deprecated`: Assigns a value to all elements (deprecated). ### Public Data Members - `T elems[N];`: The underlying array storage. ``` -------------------------------- ### Initialize boost::array with brace-enclosed initializer list Source: https://www.boost.org/doc/libs/latest/libs/array/index Aggregate initialization syntax for boost::array using brace-enclosed comma-separated list. Supports partial initialization where remaining elements are default-initialized. Fewer braces permitted per C++ standard 8.5.1(11). ```cpp boost::array a = { { 1, 2, 3 } }; boost::array a = { 1, 2, 3 }; ``` -------------------------------- ### Boost.Array Iterator Support Source: https://www.boost.org/doc/libs/latest/libs/array/index Provides methods to obtain iterators to the beginning and end of the `boost::array`. `begin()` and `end()` return mutable iterators, while `cbegin()` and `cend()` return constant iterators. These functions are `constexpr` and `noexcept`. ```cpp constexpr iterator begin() noexcept; constexpr const_iterator begin() const noexcept; constexpr const_iterator cbegin() const noexcept; constexpr iterator end() noexcept; constexpr const_iterator end() const noexcept; constexpr const_iterator cend() const noexcept; ``` -------------------------------- ### Boost.Array Front and Back Element Access Source: https://www.boost.org/doc/libs/latest/libs/array/index Methods to access the first (`front()`) and last (`back()`) elements of a `boost::array`. These methods require the array to have at least one element (`N > 0`) and are `constexpr`. ```cpp constexpr reference front(); constexpr const_reference front() const; constexpr reference back(); constexpr const_reference back() const; ``` -------------------------------- ### Capacity Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Provides information about the array's size and emptiness. ```APIDOC ## GET /array/capacity ### Description Returns information about the fixed size of the array and whether it is empty. ### Method `GET` (Conceptual - this is a class method, not a web endpoint) ### Endpoint `array::size`, `array::empty`, `array::max_size` ### Parameters None ### Request Example ```json { "array_instance": {"elems": [1, 2, 3]} } ``` ### Response #### Success Response (200) - **size** (`size_type`) - The number of elements in the array (N). - **is_empty** (`bool`) - True if the array has zero elements (N == 0), false otherwise. - **max_size** (`size_type`) - The maximum number of elements the array can hold (N). #### Response Example ```json { "size": 3, "is_empty": false, "max_size": 3 } ``` ``` -------------------------------- ### Iterator Support Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Explains how to obtain iterators for traversing the array elements. ```APIDOC ## GET /array/iterator ### Description Provides methods to get iterators for the beginning and end of the array, allowing for sequential access to elements. ### Method `GET` (Conceptual - this is a class method, not a web endpoint) ### Endpoint `array::begin`, `array::end`, `array::cbegin`, `array::cend` ### Parameters None ### Request Example ```json { "array_instance": {"elems": [1, 2, 3]} } ``` ### Response #### Success Response (200) - **begin_iterator** (`iterator` | `const_iterator`) - An iterator pointing to the first element. - **end_iterator** (`iterator` | `const_iterator`) - An iterator pointing one past the last element. #### Response Example ```json { "begin_iterator": "pointer_to_first_element", "end_iterator": "pointer_one_past_last_element" } ``` ``` -------------------------------- ### Construct/Copy/Destroy Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Details the assignment operator for copying contents from another array. ```APIDOC ## POST /array/assign ### Description Assigns the contents of another `boost::array` to the current one. Each element is assigned individually. ### Method `POST` (Conceptual - this is a class method, not a web endpoint) ### Endpoint `array::operator=` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **other** (`array&`) - Required - The source array to copy from. ### Request Example ```json { "other": { "elems": [1, 2, 3] } } ``` ### Response #### Success Response (200) - **this** (`array&`) - Reference to the modified array. #### Response Example ```json { "elems": [1, 2, 3] } ``` ``` -------------------------------- ### Convert C-style array to boost::array in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/index Creates a boost::array from a C-style array via copying or moving. Provides three overloads: lvalue reference (copy), rvalue reference (move), and const rvalue reference (copy). All declared as constexpr. ```cpp template constexpr array to_array( T const (&a)[N] ); template constexpr array to_array( T (&&a)[N] ); template constexpr array to_array( T const (&&a)[N] ); ``` -------------------------------- ### Boost.Array Element Access Operators Source: https://www.boost.org/doc/libs/latest/libs/array/index Provides access to individual elements of the `boost::array` using the `operator[]` and `at()` methods. `operator[]` offers direct access without bounds checking, while `at()` provides bounds checking and throws `std::out_of_range` if the index is invalid. Both are `constexpr`. ```cpp constexpr reference operator[](size_type i); constexpr const_reference operator[](size_type i) const; constexpr reference at(size_type i); constexpr const_reference at(size_type i) const; ``` -------------------------------- ### Element Access Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Details methods for accessing individual elements of the array, including bounds-checked and unchecked access. ```APIDOC ## GET /array/element_access ### Description Provides various ways to access elements within the array, including direct access using `operator[]` and bounds-checked access using `at()`. ### Method `GET` (Conceptual - this is a class method, not a web endpoint) ### Endpoint `array::operator[]`, `array::at`, `array::front`, `array::back`, `array::data`, `array::c_array` ### Parameters #### Query Parameters - **index** (`size_type`) - Required - The index of the element to access. ### Request Example ```json { "array_instance": {"elems": [1, 2, 3]}, "index": 1 } ``` ### Response #### Success Response (200) - **element** (`reference` | `const_reference` | `T*` | `const T*`) - The accessed element or a pointer to the underlying data. #### Response Example ```json { "element": 2 } ``` ### Error Handling - **400 Bad Request**: If `at()` is used with an index out of bounds. - **403 Forbidden**: If accessing `front()` or `back()` on an empty array. ``` -------------------------------- ### Boost.Array Reverse Iterator Support Source: https://www.boost.org/doc/libs/latest/libs/array/index These methods return reverse iterators for the `boost::array`. `rbegin()` and `rend()` provide mutable reverse iterators, while `crbegin()` and `crend()` provide constant reverse iterators. They are `noexcept`. ```cpp reverse_iterator rbegin() noexcept; const_reverse_iterator rbegin() const noexcept; const_reverse_iterator crbegin() const noexcept; reverse_iterator rend() noexcept; const_reverse_iterator rend() const noexcept; const_reverse_iterator crend() const noexcept; ``` -------------------------------- ### Create boost::array from C-style array in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Converts a C-style array (both lvalue and rvalue references) into a `boost::array`. Elements are copied for lvalue references and moved for rvalue references. ```cpp template constexpr array to_array( T const (&a)[N] ); // Returns: | an `array` `r` such that for each `i` in `[0..N)`, `r[i]` is copied from `a[i]`. ``` ```cpp template constexpr array to_array( T (&&a)[N] ); // Returns: | an `array` `r` such that for each `i` in `[0..N)`, `r[i]` is moved from `std::move(a[i])`. ``` ```cpp template constexpr array to_array( T const (&&a)[N] ); // Returns: | an `array` `r` such that for each `i` in `[0..N)`, `r[i]` is copied from `a[i]`. ``` -------------------------------- ### Reverse Iterator Support Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Details how to obtain reverse iterators for traversing the array in reverse order. ```APIDOC ## GET /array/reverse_iterator ### Description Provides methods to get reverse iterators for traversing the array elements from end to beginning. ### Method `GET` (Conceptual - this is a class method, not a web endpoint) ### Endpoint `array::rbegin`, `array::rend`, `array::crbegin`, `array::crend` ### Parameters None ### Request Example ```json { "array_instance": {"elems": [1, 2, 3]} } ``` ### Response #### Success Response (200) - **rbegin_iterator** (`reverse_iterator` | `const_reverse_iterator`) - A reverse iterator pointing to the last element. - **rend_iterator** (`reverse_iterator` | `const_reverse_iterator`) - A reverse iterator pointing one position before the first element. #### Response Example ```json { "rbegin_iterator": "reverse_pointer_to_last_element", "rend_iterator": "reverse_pointer_before_first_element" } ``` ``` -------------------------------- ### Fill array with value in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/index Assigns a given value to all elements in the array. The fill function is the preferred method; the deprecated assign function provides backward compatibility but should not be used in new code. ```cpp void fill(const T& value); void assign(const T& value); // deprecated ``` -------------------------------- ### Compare boost::array objects in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Provides comparison operators (==, !=, <, >, <=, >=) for boost::array objects. These comparisons are performed lexicographically, element by element. ```cpp template constexpr bool operator==(const array& x, const array& y); // Returns: | std::equal(x.begin(), x.end(), y.begin()). ``` ```cpp template constexpr bool operator!=(const array& x, const array& y); // Returns: | !(x == y). ``` ```cpp template constexpr bool operator<(const array& x, const array& y); // Returns: | std::lexicographical_compare(x.begin(), x.end(), y.begin(), y.end()). ``` ```cpp template constexpr bool operator>(const array& x, const array& y); // Returns: | y < x. ``` ```cpp template constexpr bool operator<=(const array& x, const array& y); // Returns: | !(y < x). ``` ```cpp template constexpr bool operator>=(const array& x, const array& y); // Returns: | !(x < y). ``` -------------------------------- ### Deprecated assign method for boost::array in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array The `assign` method is deprecated and is an obsolete spelling of the `fill` method. It is recommended to use `fill` instead for assigning a value to all elements. ```cpp void assign(const T& value); // deprecated // Effects: | fill(value). // Remarks: | An obsolete and deprecated spelling of fill. Use fill instead. ``` -------------------------------- ### Boost.Array Modifiers Source: https://www.boost.org/doc/libs/latest/libs/array/index Contains methods for modifying the `boost::array`. `fill()` sets all elements to a specified value, and `assign()` (deprecated) also serves a similar purpose. The `swap()` method exchanges the contents of two arrays. ```cpp swap(array&); constexpr void fill(const T&); void assign(const T&); // deprecated ``` -------------------------------- ### Convert C-Style Arrays to Boost Array Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Provides constexpr to_array() function overloads to convert C-style fixed-size arrays to boost::array objects. Supports lvalue arrays, rvalue arrays, and const rvalue arrays with automatic type deduction. ```cpp template constexpr array to_array( T const (&)[N] ); template constexpr array to_array( T (&&)[N] ); template constexpr array to_array( T const (&&)[N] ); ``` -------------------------------- ### Swap array contents in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/index Member function to exchange the contents of two arrays. Performs element-wise swap with linear time complexity proportional to array size N. Also provides a standalone template function for the same operation. ```cpp void swap(array& other); template void swap(array& x, array& y); ``` -------------------------------- ### Modifiers Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Explains methods for modifying the array's contents, such as filling with a value or swapping with another array. ```APIDOC ## POST /array/modify ### Description Provides methods to modify the contents of the array, including filling all elements with a specific value or swapping its contents with another array. ### Method `POST` (Conceptual - this is a class method, not a web endpoint) ### Endpoint `array::swap`, `array::fill`, `array::assign` ### Parameters #### Request Body - **value** (`T`) - Optional - The value to fill the array with (for `fill` and `assign`). - **other_array** (`array&`) - Optional - The array to swap contents with (for `swap`). ### Request Example ```json { "operation": "fill", "value": 5 } ``` ### Response #### Success Response (200) - **status** (`string`) - Indicates the success of the operation. #### Response Example ```json { "status": "Array filled successfully." } ``` ``` -------------------------------- ### Boost.Array Class Definition Source: https://www.boost.org/doc/libs/latest/libs/array/index The C++ code defines the `boost::array` class template, which provides a fixed-size array container. It includes definitions for value types, iterators, reverse iterators, size types, and constructors. The class supports various operations like element access, capacity checks, and modification. ```cpp // In header: template class array { public: // types typedef T value_type; typedef T* iterator; typedef const T* const_iterator; typedef std::reverse_iterator reverse_iterator; typedef std::reverse_iterator const_reverse_iterator; typedef T& reference; typedef const T& const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; // static constants static const size_type static_size = N; // construct/copy/destroy template array& operator=(const array&); // iterator support constexpr iterator begin() noexcept; constexpr const_iterator begin() const noexcept; constexpr const_iterator cbegin() const noexcept; constexpr iterator end() noexcept; constexpr const_iterator end() const noexcept; constexpr const_iterator cend() const noexcept; // reverse iterator support reverse_iterator rbegin() noexcept; const_reverse_iterator rbegin() const noexcept; const_reverse_iterator crbegin() const noexcept; reverse_iterator rend() noexcept; const_reverse_iterator rend() const noexcept; const_reverse_iterator crend() const noexcept; // capacity static constexpr size_type size() noexcept; static constexpr bool empty() noexcept; static constexpr size_type max_size() noexcept; // element access constexpr reference operator[](size_type); constexpr const_reference operator[](size_type) const; constexpr reference at(size_type); constexpr const_reference at(size_type) const; constexpr reference front(); constexpr const_reference front() const; constexpr reference back(); constexpr const_reference back() const; constexpr T* data() noexcept; constexpr const T* data() const noexcept; T* c_array() noexcept; // deprecated // modifiers swap(array&); constexpr void fill(const T&); void assign(const T&); // deprecated // public data members T elems[N]; }; ``` -------------------------------- ### Access array elements by index in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Provides access to individual elements of a boost::array using a compile-time index. Access is bounds-checked at compile time, requiring `Idx < N`. ```cpp template constexpr T& get(array& arr) noexcept; // Mandates: | Idx < N. // Returns: | arr[Idx]. ``` ```cpp template constexpr const T& get(const array& arr) noexcept; // Mandates: | Idx < N. // Returns: | arr[Idx]. ``` -------------------------------- ### Compare Arrays for Ordering in Boost Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Defines constexpr relational operators (<, >, <=, >=) for ordering comparison of boost::array objects and the three-way comparison operator (<=>). These enable lexicographic comparison and are marked constexpr for constant expression evaluation. ```cpp template constexpr bool operator<(const array&, const array&); template constexpr bool operator>(const array&, const array&); template constexpr bool operator<=(const array&, const array&); template constexpr bool operator>=(const array&, const array&); template constexpr auto operator<=>(const array&, const array&); ``` -------------------------------- ### Swap Arrays in Boost Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Provides a swap function for exchanging contents of two boost::array objects with the same type and size. This function enables efficient array swapping while maintaining STL container compatibility. ```cpp template void swap(array&, array&); ``` -------------------------------- ### Fill array with a specific value in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Assigns a given value to all elements of the boost::array. This operation iterates through all elements, performing an assignment for each. ```cpp void fill(const T& value); // Effects: | For each i in [0..N), performs elems[i] = value;. ``` -------------------------------- ### Three-way comparison for boost::array in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Implements the three-way comparison operator (<=>) for boost::array objects. It compares elements lexicographically and returns a std::strong_ordering result. ```cpp template constexpr auto operator<=>(const array& x, const array& y) -> decltype(x[0] <=> y[0]); // Effects: | For each i in [0..N), if (x[i] <=> y[i]) != 0, returns x[i] <=> y[i]. Otherwise, returns std::strong_ordering::equal, converted to the return type. // Remarks: | When N is 0, the return type is std::strong_ordering and the return value is std::strong_ordering::equal. ``` -------------------------------- ### Define Boost Array Template Class Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Declares the boost::array template class for fixed-size arrays of type T with compile-time size N. This is the core template definition that provides STL container interface without dynamic memory management overhead. ```cpp template class array; ``` -------------------------------- ### Inequality comparison operator for arrays in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/index Compares two arrays for inequality. Returns the logical negation of the equality operator. Declared as constexpr for compile-time evaluation. ```cpp template constexpr bool operator!=(const array& x, const array& y); ``` -------------------------------- ### Three-way comparison operator for arrays in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/index Performs lexicographical three-way comparison (spaceship operator) between two arrays. Returns strong_ordering::equal for empty arrays (N=0) or the result of the first non-equal element comparison. Declared as constexpr. ```cpp template constexpr auto operator<=>(const array& x, const array& y) -> decltype(x[0] <=> y[0]); ``` -------------------------------- ### Less-than-or-equal comparison operator for arrays in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/index Compares if first array is less than or equal to second. Declared as constexpr for compile-time evaluation. ```cpp template constexpr bool operator<=(const array& x, const array& y); ``` -------------------------------- ### Compare Arrays for Equality in Boost Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Defines constexpr equality and inequality operators for comparing two boost::array objects. These operators enable compile-time array comparison and are marked constexpr for use in constant expressions. ```cpp template constexpr bool operator==(const array&, const array&); template constexpr bool operator!=(const array&, const array&); ``` -------------------------------- ### Equality comparison operator for arrays in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/index Compares two arrays for equality using std::equal. Returns true if all corresponding elements are equal, false otherwise. Declared as constexpr for compile-time evaluation. ```cpp template constexpr bool operator==(const array& x, const array& y); ``` -------------------------------- ### Greater-than comparison operator for arrays in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/index Compares if first array is greater than second using reverse of less-than operator. Declared as constexpr for compile-time evaluation. ```cpp template constexpr bool operator>(const array& x, const array& y); ``` -------------------------------- ### Swap array elements in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Swaps the contents of two boost::array objects. This operation has linear complexity with respect to the size of the array. ```cpp void swap(array& other); // Effects: | std::swap(elems, other.elems). // Complexity: | linear in N. ``` ```cpp template void swap(array& x, array& y); // Effects: | x.swap(y). ``` -------------------------------- ### Greater-than-or-equal comparison operator for arrays in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/index Compares if first array is greater than or equal to second. Declared as constexpr for compile-time evaluation. ```cpp template constexpr bool operator>=(const array& x, const array& y); ``` -------------------------------- ### Boost.Array Copy Assignment Operator Source: https://www.boost.org/doc/libs/latest/libs/array/index The copy assignment operator `=` for `boost::array` allows assignment from another `boost::array` with potentially different element types (`U`). It performs element-wise assignment for all elements in the array. ```cpp template array& operator=(const array& other); ``` -------------------------------- ### Less-than comparison operator for arrays in C++ Source: https://www.boost.org/doc/libs/latest/libs/array/index Performs lexicographical comparison of two arrays. Returns true if the first array is lexicographically less than the second. Declared as constexpr for compile-time evaluation. ```cpp template constexpr bool operator<(const array& x, const array& y); ``` -------------------------------- ### Boost.Array Modifiers: fill and assign Source: https://www.boost.org/doc/libs/latest/libs/array/doc/html/array Member functions for modifying the contents of a Boost.Array. `fill()` assigns a given value to all elements, while the deprecated `assign()` function (also for filling) is also mentioned. ```cpp constexpr void fill(const T&); void assign(const T&); // deprecated ```