Skip to content

Commit

Permalink
Check for the size of the input for one of the constructors
Browse files Browse the repository at this point in the history
And also static_cast to float, because with older GCC and Clang this is fine,
newer GCC throws a warning and newer Clang a compilation error if it's a double.
  • Loading branch information
jmcarcell committed Jul 29, 2024
1 parent d409c53 commit 197b431
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions edm4hep.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ components:
declaration: "
constexpr CovMatrix2f() = default;\n
template<typename... Vs>\n
constexpr CovMatrix2f(Vs... v) : values{v...} {}\n
constexpr CovMatrix2f(Vs... v) : values{static_cast<float>(v)...} {
static_assert(sizeof...(v) == 3, \"CovMatrix2f requires 3 values\");
}\n
constexpr CovMatrix2f(const std::array<float, 3>& v) : values(v) {}\n
constexpr CovMatrix2f& operator=(std::array<float, 3>& v) { values = v; return *this; }\n
bool operator==(const CovMatrix2f& v) const { return v.values == values; }\n
Expand All @@ -148,7 +150,9 @@ components:
constexpr CovMatrix3f() = default;\n
constexpr CovMatrix3f(const std::array<float, 6>& v) : values(v) {}\n
template<typename... Vs>\n
constexpr CovMatrix3f(Vs... v) : values{v...} {}\n
constexpr CovMatrix3f(Vs... v) : values{static_cast<float>(v)...} {
static_assert(sizeof...(v) == 6, \"CovMatrix3f requires 6 values\");
}\n
constexpr CovMatrix3f& operator=(std::array<float, 6>& v) { values = v; return *this; }\n
bool operator==(const CovMatrix3f& v) const { return v.values == values; }\n
bool operator!=(const CovMatrix3f& v) const { return v.values != values; }\n
Expand All @@ -164,7 +168,9 @@ components:
declaration: "
constexpr CovMatrix4f() = default;\n
template<typename... Vs>\n
constexpr CovMatrix4f(Vs... v) : values{v...} {}\n
constexpr CovMatrix4f(Vs... v) : values{static_cast<float>(v)...} {
static_assert(sizeof...(v) == 10, \"CovMatrix4f requires 10 values\");
}\n
constexpr CovMatrix4f(const std::array<float, 10>& v) : values(v) {}\n
constexpr CovMatrix4f& operator=(std::array<float, 10>& v) { values = v; return *this; }\n
bool operator==(const CovMatrix4f& v) const { return v.values == values; }\n
Expand All @@ -182,7 +188,9 @@ components:
declaration: "
constexpr CovMatrix6f() = default;\n
template<typename... Vs>\n
constexpr CovMatrix6f(Vs... v) : values{v...} {}\n
constexpr CovMatrix6f(Vs... v) : values{static_cast<float>(v)...} {
static_assert(sizeof...(v) == 21, \"CovMatrix6f requires 21 values\");
}\n
constexpr CovMatrix6f(const std::array<float, 21>& v) : values(v) {}\n
constexpr CovMatrix6f& operator=(std::array<float, 21>& v) { values = v; return *this; }\n
bool operator==(const CovMatrix6f& v) const { return v.values == values; }\n
Expand Down

0 comments on commit 197b431

Please sign in to comment.