Namespaces | Functions
ConstantExpressions.hpp File Reference

Define simple functions for constant expressions. More...

#include <algorithm>
#include <array>
#include <blaze/math/typetraits/IsVector.h>
#include <cassert>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <initializer_list>
#include <utility>
#include "Utilities/ForceInline.hpp"
#include "Utilities/MakeWithValue.hpp"
#include "Utilities/Requires.hpp"
#include "Utilities/TMPL.hpp"
#include "Utilities/TypeTraits.hpp"

Go to the source code of this file.

Namespaces

 cpp17
 C++ STL code present in C++17.
 

Functions

template<typename T , Requires< tt::is_integer_v< T > and cpp17::is_unsigned_v< T >> = nullptr>
constexpr T two_to_the (T n)
 Compute 2 to the n for integral types. More...
 
constexpr size_t get_nth_bit (const size_t i, const size_t N)
 Get the nth bit from the right, counting from zero. More...
 
template<typename T >
decltype(auto) constexpr square (const T &x)
 Compute the square of x
 
template<typename T >
decltype(auto) constexpr cube (const T &x)
 Compute the cube of x
 
constexpr uint64_t falling_factorial (const uint64_t x, const uint64_t n) noexcept
 Compute the falling factorial of \((x)_{n}\). More...
 
constexpr uint64_t factorial (const uint64_t n) noexcept
 Compute the factorial of \(n!\).
 
template<int N, typename T >
decltype(auto) constexpr pow (const T &t) noexcept
 Compute t^N where N is an integer (positive or negative) More...
 
template<typename T , Requires< tt::is_integer_v< T > or cpp17::is_floating_point_v< T >> = nullptr>
constexpr T ce_abs (const T &x) noexcept(noexcept(x< 0 ? -x :x))
 Compute the absolute value of of its argument. More...
 
constexpr double ce_fabs (const double x) noexcept
 Compute the absolute value of its argument.
 
constexpr float ce_fabs (const float x) noexcept
 
template<class T , class Compare = std::less<>>
constexpr const T & cpp17::clamp (const T &v, const T &lo, const T &hi, Compare comp=Compare())
 Clamps the value between lo and hi. More...
 
template<size_t NumTerms, typename Function , Requires< NumTerms==1 > = nullptr>
decltype(auto) constexpr constexpr_sum (Function &&f) noexcept
 Returns f(ic<0>{}) + f(ic<1>{}) + ... + f(ic<NumTerms-1>{}) where ic<N> stands for std::integral_constant<size_t, N>. This function allows the result types of each operation to be different, and so works efficiently with expression templates. More...
 
template<typename List , Requires< not tt::is_a_v< tmpl::list, tmpl::front< List >>> = nullptr>
constexpr auto make_array_from_list () -> std::array< std::decay_t< decltype(tmpl::front< List >::value)>, tmpl::size< List >::value >
 Make an array from a typelist that holds std::integral_constant's all of which have the same value_type More...
 
template<typename TypeForZero , Requires< not tt::is_a_v< tmpl::list, TypeForZero >> = nullptr>
constexpr std::array< std::decay_t< TypeForZero >, 0 > make_array_from_list ()
 
constexpr size_t cstring_length (const char *str) noexcept
 Compute the length of a const char* at compile time.
 
constexpr size_t cstring_hash (const char *str) noexcept
 Compute a hash of a const char* at compile time.
 
template<size_t I, typename T , size_t Size>
constexpr std::array< std::decay_t< T >, Size > replace_at (const std::array< T, Size > &arr, T value)
 Replace at compile time the Ith entry in the array with value
 
template<typename T , typename S , size_t size>
constexpr bool array_equal (const std::array< T, size > &lhs, const std::array< S, size > &rhs, const size_t i=0) noexcept
 Check at compile time if two std::arrays are equal.
 
template<typename T >
constexpr const T & cpp17::as_const (const T &t) noexcept
 Returns a const reference to its argument.
 
template<typename T >
constexpr const T & max_by_magnitude (const T &a, const T &b)
 Return the argument with the largest magnitude. More...
 
template<typename T >
constexpr T max_by_magnitude (std::initializer_list< T > ilist)
 Return the argument with the largest magnitude. More...
 
template<typename T >
constexpr const T & min_by_magnitude (const T &a, const T &b)
 Return the argument with the smallest magnitude. More...
 
template<typename T >
constexpr T min_by_magnitude (std::initializer_list< T > ilist)
 Return the argument with the smallest magnitude. More...
 

Detailed Description

Define simple functions for constant expressions.