Macros | Functions
StdArrayHelpers.hpp File Reference

Defines arithmetic operators for std::array and other helpful functions. More...

#include <array>
#include <cmath>
#include <cstddef>
#include <type_traits>
#include <utility>
#include "ErrorHandling/Assert.hpp"
#include "Utilities/Gsl.hpp"

Go to the source code of this file.

Macros

#define DEFINE_STD_ARRAY_BINOP(RESULT_TYPE, LTYPE, RTYPE, OP_FUNCTION_NAME, BINARY_OP)
 Declares a binary function on an array, intended for binary operators such as + More...
 
#define DEFINE_STD_ARRAY_INPLACE_BINOP(LTYPE, RTYPE, OP_FUNCTION_NAME, BINARY_OP)
 Declares an in-place binary function on an array, intended for operations such as += More...
 

Functions

template<size_t Dim, typename T , typename U >
std::array< T, Dim > & operator+= (std::array< T, Dim > &lhs, const std::array< U, Dim > &rhs) noexcept
 
template<size_t Dim, typename T , typename U >
auto operator+ (const std::array< T, Dim > &lhs, const std::array< U, Dim > &rhs) noexcept -> std::array< decltype(lhs[0]+rhs[0]), Dim >
 
template<size_t Dim, typename T , typename U >
std::array< T, Dim > & operator-= (std::array< T, Dim > &lhs, const std::array< U, Dim > &rhs) noexcept
 
template<size_t Dim, typename T , typename U >
auto operator- (const std::array< T, Dim > &lhs, const std::array< U, Dim > &rhs) noexcept -> std::array< decltype(lhs[0] - rhs[0]), Dim >
 
template<size_t Dim, typename T , typename U >
std::array< T, Dim > operator* (const std::array< T, Dim > &lhs, const U &scale) noexcept
 
template<size_t Dim, typename T , typename U >
std::array< T, Dim > operator* (const U &scale, const std::array< T, Dim > &rhs) noexcept
 
template<size_t Dim, typename T , typename U >
std::array< T, Dim > operator/ (const std::array< T, Dim > &lhs, const U &scale) noexcept
 
template<size_t Dim, typename T >
std::array< T, Dim > operator- (const std::array< T, Dim > &rhs) noexcept
 
template<typename T , size_t Dim>
std::array< T, Dim - 1 > all_but_specified_element_of (const std::array< T, Dim > &a, const size_t element_to_remove) noexcept
 Construct an array from an existing array omitting one element.
 
template<typename T , size_t Dim>
std::array< T, Dim+1 > insert_element (std::array< T, Dim > a, const size_t element_to_add, T value) noexcept
 Construct an array from an existing array adding one element.
 
template<typename T , size_t Dim>
constexpr std::array< T, Dim+1 > prepend (const std::array< T, Dim > &a, T value) noexcept
 Construct an array from an existing array prepending a value.
 
template<typename T , size_t Dim, typename F >
auto map_array (const std::array< T, Dim > &array, const F &f) noexcept
 Applies a function to each element of an array, producing a new array of the results. The elements of the new array are constructed in place, so they need not be default constructible.
 
template<typename T >
magnitude (const std::array< T, 1 > &a) noexcept
 Euclidean magnitude of the elements of the array. More...
 
template<>
double magnitude (const std::array< double, 1 > &a) noexcept
 Euclidean magnitude of the elements of the array. More...
 
template<typename T >
magnitude (const std::array< T, 2 > &a) noexcept
 Euclidean magnitude of the elements of the array. More...
 
template<typename T >
magnitude (const std::array< T, 3 > &a) noexcept
 Euclidean magnitude of the elements of the array. More...
 

Detailed Description

Defines arithmetic operators for std::array and other helpful functions.