Stratax
Scientific computing containers and operations
Loading...
Searching...
No Matches
Validation.hpp File Reference

Shared runtime validation helpers. More...

#include <cstddef>
#include <limits>
#include <type_traits>
#include <stratax/core/Concepts.hpp>
#include <stratax/core/Exceptions.hpp>

Go to the source code of this file.

Namespaces

namespace  stratax
namespace  stratax::core
namespace  stratax::core::validation

Functions

template<typename Actual, typename Expected>
void stratax::core::validation::require_type (const char *message)
 Requires a type to exactly match an expected type after cv/ref removal.
template<typename T>
void stratax::core::validation::require_numeric_type (const char *message)
 Requires a type to satisfy Stratax's numeric type rules.
template<typename Lhs, typename Rhs>
requires requires { typename Lhs::value_type; typename Rhs::value_type; }
void stratax::core::validation::require_same_value_type (const Lhs &, const Rhs &, const char *message)
 Requires two array-like objects to have the same value type.
std::size_t stratax::core::validation::nonnegative_size (long long value, const char *message)
 Converts a signed value to std::size_t after rejecting negatives.
std::size_t stratax::core::validation::nonnegative_shape_dimension (long long value, const char *message)
 Converts a signed shape dimension to std::size_t after rejecting negatives.
std::size_t stratax::core::validation::positive_shape_dimension (long long value, const char *message)
 Converts a signed shape dimension to std::size_t after requiring it to be positive.
void stratax::core::validation::require_positive_shape_dimension (std::size_t value, const char *message)
 Requires an unsigned shape dimension to be positive.
std::size_t stratax::core::validation::nonnegative_index (long long value, const char *message)
 Converts a signed index to std::size_t after rejecting negatives.
void stratax::core::validation::require_rank (std::size_t actual, std::size_t expected, const char *message)
 Requires a rank value to match an expected rank.
template<typename Ranked>
requires requires(const Ranked& object) { object.rank(); }
const Ranked & stratax::core::validation::require_rank (const Ranked &object, std::size_t expected, const char *message)
 Requires an object with rank() to match an expected rank.
void stratax::core::validation::require_index (std::size_t index, std::size_t size, const char *message)
 Requires an index to be less than a size.
void stratax::core::validation::require_at_most (std::size_t value, std::size_t upper, const char *message)
 Requires a value to be less than or equal to an upper bound.
std::size_t stratax::core::validation::checked_multiply (std::size_t lhs, std::size_t rhs, const char *message)
 Multiplies two sizes while checking for overflow.
std::size_t stratax::core::validation::checked_add (std::size_t lhs, std::size_t rhs, const char *message)
 Adds two sizes while checking for overflow.
template<typename Lhs, typename Rhs>
bool stratax::core::validation::same_shape (const Lhs &lhs, const Rhs &rhs)
 Returns whether two array-like objects have identical size and shape.
template<typename Lhs, typename Rhs>
void stratax::core::validation::require_same_shape (const Lhs &lhs, const Rhs &rhs, const char *message)
 Requires two array-like objects to have identical size and shape.
void stratax::core::validation::require_equal_size (std::size_t lhs, std::size_t rhs, const char *message)
 Requires two sizes to be equal.

Detailed Description

Shared runtime validation helpers.

Definition in file Validation.hpp.