У меня есть следующий компилятор и установленные флаги:< /p>
- флаги: g++ -std=c++17 -O3 -msse2
Код: Выделить всё
x86-64 gcc 14.1
Вот сгенерированная ошибка
Код: Выделить всё
:66:5: error: extra qualification 'Mat4::' on member
'operator+' [-fpermissive]
66 | Mat4::operator+(const Mat4& other) const {
| ^~~~~~~
Источник: sample.cpp
Код: Выделить всё
#include // std::clamp
#include // std::uint8_t
#include // SSE/SSE2 intrinsics
#include // std::is_floating_point,std::is_integral
constexpr std::uint8_t stride = 4;
constexpr std::uint8_t size = 16;
template
struct Mat4 {
T data[size];
// Other operators here:
Mat4 operator+(const Mat4& other) const;
// Other arithmetic operators here:
// Integral types using SSE2
template
typename std::enable_if::type
Mat4::operator+(const Mat4& other) const {
Mat4 result;
for (std::uint8_t i = 0; i < size; i += stride) {
__m128i a = _mm_loadu_si128(reinterpret_cast(&data[i]));
__m128i b = _mm_loadu_si128(reinterpret_cast(&other.data[i]));
__m128i c = _mm_add_epi32(a, b); // Change this to _mm_add_epi64 for 64-bit integers
_mm_storeu_si128(reinterpret_cast(&result.data[i]), c);
}
return result;
}
// Other Integer Type arithmetic operators here.
};
// Specialization for floating-point types
template
Mat4 Mat4::operator+(const Mat4& other) const {
Mat4 result;
for (std::uint8_t i = 0; i < size; i += stride) {
__m128 a = _mm_loadu_ps(&data[i]);
__m128 b = _mm_loadu_ps(&other.data[i]);
__m128 c = _mm_add_ps(a, b);
_mm_storeu_ps(&result.data[i], c);
}
return result;
}
// Other floating-point type specialization arithmetic operators here
Я даже попытался переключить компилятор на MSVC и получил аналогичную ошибку компилятора, но все равно безуспешно, и в конце концов я вернулся обратно к GCC.
Я даже попытался переключить компилятор на MSVC и получил аналогичную ошибку компилятора, но все равно безуспешно. п>
Подробнее здесь: https://stackoverflow.com/questions/786 ... -generatin