Version: v0.2.0
Status: Complete
Header: include/stratax/core/Concepts.hpp
Overview
Concepts.hpp defines Stratax compile-time constraints for scalar categories and array-like container categories.
These concepts gate template overloads and class declarations without adding runtime overhead.
Responsibilities
The concepts module is responsible for:
- Classifying scalar types into numeric categories
- Restricting accepted array container types for generic ops
- Providing structural ND-array concept checks for generic algorithms
The concepts module is not responsible for:
- Runtime validation or exception throwing
- Value-level semantics (broadcasting, promotion, precision policy)
- Container implementation details
Relationships
concept_detail
├── clean_t
├── SameAsAny
├── CharacterLike / BoolLike
└── SupportedComplex
Public concepts
├── Integral / Integer / SignedInteger / UnsignedInteger
├── Floating / Float / Arithmetic / Real
├── Complex / Numeric / Scalar
└── Array / NDarray
Depends on:
Used by:
- Container templates (Vector, Matrix, Tensor)
- Ops and algorithms overload constraints
Invariants
The following conditions are always true:
- Type checks normalize cv/ref qualifiers via clean_t.
- Integral excludes bool-like and character-like types.
- Complex accepts only supported std::complex<float|double|long double>.
- Numeric equals Arithmetic || Complex.
- Array recognizes Stratax container specializations via is_array.
- NDarray is structural (shape, size, begin, end required).
Public Interface
Scalar concepts
template<typename T> concept
Integer;
template<typename T> concept
Float;
template<typename T> concept
Real;
template<typename T> concept
Complex;
template<typename T> concept
Numeric;
template<typename T> concept
Scalar;
Matches arithmetic scalar types.
Matches supported complex scalar types.
Alias for Stratax-supported floating-point types.
Matches floating-point types.
Alias for Stratax-supported integer types.
Matches signed and unsigned integral types, excluding character-like types.
Matches all scalar types supported by Stratax numeric containers.
Matches real numeric scalar types.
Alias for any scalar type accepted by Stratax numeric containers.
Matches supported signed integer types.
Matches supported unsigned integer types.
Container declarations and traits
template<
typename T>
requires Numeric<T> class Vector;
template<
typename T>
requires Numeric<T> class Matrix;
template<
typename T>
requires Numeric<T> class Tensor;
}
Type trait that reports whether a type is a Stratax array.
Container concepts
template<
typename T>
concept Array;
template<typename T> concept
NDarray;
Matches array-like container types with shape, size, and iteration support.
Complexity Summary
| Operation | Complexity |
| Concept checks (Integral, Numeric, Array) | Compile-time only |
| Structural requirement checks (NDarray) | Compile-time only |
| Runtime overhead introduced by concepts | O(0) |
Examples
template<Numeric T>
T twice(T value)
{
return value + value;
}
template<Array A>
A add_arrays(const A& lhs, const A& rhs)
{
return lhs + rhs;
}
Design Notes
Concepts deliberately separate accepted Stratax array types (Array) from structural array-like requirements (NDarray) so APIs can choose strict or generic constraints.
Character-like exclusions prevent accidental acceptance of textual byte-like types as numeric scalar data.
Future Improvements
- Add concepts for matrix-only and tensor-only constraints
- Add explicit promotion-related concepts for mixed-type arithmetic
- Add regression tests for accepted/rejected edge-case types
See Also