Added fennec::allocation and all necessary dependencies

This commit is contained in:
2025-05-30 21:10:52 -04:00
parent 1a27e37f66
commit 67c8ad9a0d
24 changed files with 847 additions and 74 deletions

View File

@@ -24,11 +24,15 @@
namespace fennec
{
template<typename ScalarT, size_t...IndicesV> struct vector;
template<typename ScalarT, size_t RowsV, size_t...ColIndicesV> struct matrix;
template<typename ScalarT, size_t...IndicesV> struct vector; // Forward def for vectors
template<typename ScalarT, size_t RowsV, size_t...ColIndicesV> struct matrix; // Forward def for matrices
template<typename ScalarT, size_t SizeV> using vec = decltype(detail::__gen_vector<vector, ScalarT>(make_index_sequence<SizeV>{}));
template<typename ScalarT, size_t RowsV, size_t ColsV> using mat = decltype(detail::__gen_matrix<matrix, ScalarT, RowsV>(make_index_sequence<ColsV>{}));
// Simplified interface for creating sized vectors or matrices
template<typename ScalarT, size_t SizeV> using vec
= decltype(detail::__gen_vector<vector, ScalarT>(make_index_sequence<SizeV>{})); // Gets the type returned by this function
template<typename ScalarT, size_t RowsV, size_t ColsV> using mat
= decltype(detail::__gen_matrix<matrix, ScalarT, RowsV>(make_index_sequence<ColsV>{})); // Gets the type returned by this function
}

View File

@@ -28,11 +28,11 @@ namespace detail
{
template<template<typename, size_t...> typename VectorT, typename ScalarT, size_t...IndicesV>
VectorT<ScalarT, IndicesV...> __gen_vector(index_sequence<IndicesV...>);
VectorT<ScalarT, IndicesV...> __gen_vector(index_sequence<IndicesV...>); // Helper for substituting a size N with sequence of integers
template<template<typename, size_t...> typename MatrixT, typename ScalarT, size_t RowsV, size_t...IndicesV>
MatrixT<ScalarT, RowsV, IndicesV...> __gen_matrix(index_sequence<IndicesV...>);
MatrixT<ScalarT, RowsV, IndicesV...> __gen_matrix(index_sequence<IndicesV...>); // Helper for substituting a size Columns with sequence of integers
}

View File

@@ -30,43 +30,47 @@ namespace fennec
namespace detail
{
// Helpers for vector traits
template<typename>
struct __is_vector_helper
: false_type {};
: false_type {}; // Default false case
template<typename ScalarT, size_t...IndicesV>
struct __is_vector_helper<vector<ScalarT, IndicesV...>>
: true_type {};
: true_type {}; // True for vectors
template<typename VectorT, typename DataT, typename ScalarT, size_t...IndicesV>
struct __is_vector_helper<swizzle<VectorT, DataT, ScalarT, IndicesV...>>
: true_type {};
: true_type {}; // True for swizzles
// get number of components of a type
template<typename>
struct __component_count_helper;
// numeric types reduce to 1
template<typename TypeT> requires(is_arithmetic_v<TypeT>)
struct __component_count_helper<TypeT>
: integral_constant<size_t, 1> {};
// Vectors reduce to the number of elements
template<typename ScalarT, size_t...IndicesV>
struct __component_count_helper<vector<ScalarT, IndicesV...>>
: integral_constant<size_t, sizeof...(IndicesV)> {};
// Swizzles reduce to number of elements
template<typename VectorT, typename DataT, typename ScalarT, size_t...IndicesV>
struct __component_count_helper<swizzle<VectorT, DataT, ScalarT, IndicesV...>>
: integral_constant<size_t, sizeof...(IndicesV)> {};
// Matrices reduce to the number of cells
template<typename ScalarT, size_t RowsV, size_t...ColIndicesV>
struct __component_count_helper<matrix<ScalarT, RowsV, ColIndicesV...>>
: integral_constant<size_t, RowsV * sizeof...(ColIndicesV)> {};
// default case reduces to 0
template<typename>
struct __component_count_helper
: integral_constant<size_t, 0> {};