Added additional constraints to list instantiation
This commit is contained in:
+1
-1
@@ -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)
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@ Matrix<rows, columns>::Matrix(const std::array<float, rows * columns> &array) {
|
||||
}
|
||||
|
||||
template <uint8_t rows, uint8_t columns>
|
||||
template <typename... Args>
|
||||
template <typename... Args,
|
||||
std::enable_if_t<(std::is_arithmetic_v<Args> && ...), int>>
|
||||
Matrix<rows, columns>::Matrix(Args... args) {
|
||||
constexpr uint16_t arraySize{static_cast<uint16_t>(rows) *
|
||||
static_cast<uint16_t>(columns)};
|
||||
|
||||
+6
-2
@@ -3,6 +3,7 @@
|
||||
#include <array>
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
// TODO: Add a function to calculate eigenvalues/vectors
|
||||
// TODO: Add a function to compute RREF
|
||||
@@ -29,9 +30,12 @@ public:
|
||||
Matrix(const Matrix<rows, columns> &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 <typename... Args> Matrix(Args... args);
|
||||
template <typename... Args,
|
||||
std::enable_if_t<(std::is_arithmetic_v<Args> && ...), int> = 0>
|
||||
Matrix(Args... args);
|
||||
|
||||
/**
|
||||
* @brief Create an identity matrix
|
||||
|
||||
Reference in New Issue
Block a user