From a49e357f4c8a989925194833c78a0a855f215f72 Mon Sep 17 00:00:00 2001 From: Cynopolis Date: Thu, 13 Aug 2026 11:33:19 -0400 Subject: [PATCH] Added additional constraints to list instantiation --- CMakeLists.txt | 2 +- src/Matrix.cpp | 3 ++- src/Matrix.hpp | 8 ++++++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4f6270..62bd4f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,7 +4,7 @@ project(Vector3D) add_subdirectory(src) add_subdirectory(unit-tests) -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 17) add_compile_options(-Wall -Wextra -Wpedantic) add_compile_options (-fdiagnostics-color=always) diff --git a/src/Matrix.cpp b/src/Matrix.cpp index f129fde..a4ea714 100644 --- a/src/Matrix.cpp +++ b/src/Matrix.cpp @@ -20,7 +20,8 @@ Matrix::Matrix(const std::array &array) { } template -template +template && ...), int>> Matrix::Matrix(Args... args) { constexpr uint16_t arraySize{static_cast(rows) * static_cast(columns)}; diff --git a/src/Matrix.hpp b/src/Matrix.hpp index d4b1798..1c28a08 100644 --- a/src/Matrix.hpp +++ b/src/Matrix.hpp @@ -3,6 +3,7 @@ #include #include #include +#include // TODO: Add a function to calculate eigenvalues/vectors // TODO: Add a function to compute RREF @@ -29,9 +30,12 @@ public: Matrix(const Matrix &other); /** - * @brief Initialize a matrix directly with any number of arguments + * @brief Initialize a matrix directly with scalar values + * Uses SFINAE to only accept arithmetic types (int, float, double, etc.) */ - template Matrix(Args... args); + template && ...), int> = 0> + Matrix(Args... args); /** * @brief Create an identity matrix