Int17Matrix3D Int17Matrix3D::make_array(int x, int y, int z) {
return Int17Matrix3D(x, y, z);
}
int32_t Int17Matrix3D::GetValueAt(int x, int y, int z) const{
int index = GetIndex(x, y, z);
// Проверьте диапазон для x, y и z перед доступом к массиву
return ToDecimal(array_, index); // Может потребоваться изменить остальную логику
}
for (int i = 0; i < kNumLenght_; ++i) {
if (TakeBit(array_, first_bit_index + i)) {
decimal_value += exp;
}
exp <<= 1;
}
return decimal_value;
}
Int17Matrix3D Int17Matrix3D::operator+(const Int17Matrix3D& other) {
if (this->width_ != other.width_ || this->height_ != other.height_ || this->depth_ != other.depth_) {
throw std::out_of_range("Arrays must be with the same size");
}
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
Int17Matrix3D Int17Matrix3D::operator-(const Int17Matrix3D& other) {
if (this->width_ != other.width_ || this->height_ != other.height_ || this->depth_ != other.depth_) {
throw std::out_of_range("Arrays must be with the same size");
}
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
[ 7%] Building CXX object lib/CMakeFiles/Int17Matrix3D.dir/Int17Matrix3D.cpp.o
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.cpp:58:22: error: out-of-line definition of 'operator[]' does not match any declaration in 'Int17Matrix3D'
Proxy Int17Matrix3D::operator[](int x) {
^~~~~~~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.cpp:63:12: error: non-const lvalue reference to type 'int32_t' (aka 'int') cannot bind to a temporary of type 'int32_t'
return matrix_.GetValueAt(x_, y_, z);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
make[2]: *** [lib/CMakeFiles/Int17Matrix3D.dir/Int17Matrix3D.cpp.o] Error 1
make[1]: *** [lib/CMakeFiles/Int17Matrix3D.dir/all] Error 2
make: *** [all] Error 2
Assistant
The error messages from the compiler indicate two issues with your Int17Matrix3D class.
The operator[] defined out-of-line is not matching any declaration in Int17Matrix3D. This is because in your class definition, you have commented out the line declaring this operator, which means the compiler cannot find a matching declaration for the definition you've provided.
You're trying to return a reference (int32_t&) to a temporary object (int32_t). Temporary objects cannot have non-const references bound to them as they're about to be destroyed after the expression that creates them ends. This is happening in the ProxyInt's operator[] where you're calling matrix_.GetValueAt() which returns an int32_t, not an int32_t&.
Here's how you can resolve these errors:
Uncomment the declaration of operator[] in the Int17Matrix3D class to provide a matching declaration for the definition in the .cpp file:
cpp
Int17Matrix3D& operator[](int index); // remove the comment
Modify the ProxyInt's operator[] to either return a value or create a way to return a reference to an actual element in Int17Matrix3D.
One possible way to do this is to modify the GetValueAt method to return a reference:
cpp
int32_t& GetValueAt(int x, int y, int z);
You'll need to ensure that GetValueAt returns a valid reference to an element within your array_ instead of converting bits to a decimal value, which cannot be returned as a non-const reference.
Keep in mind that if you intend to provide access to the matrix elements through subscript operators like matrix[a][b][c], you'll need to ensure that the intermediaries (Proxy and ProxyInt) allow for eventually accessing a real location in memory. This often involves storing additional information in these proxy classes that enables them to reference the correct element. You'll also need to carefully check that your bit manipulation logic in SetValueAtCurrentIndex, ToDecimal, SetBit, and ClearBit in Int17Matrix3D supports such direct element access.
The errors indicate that there are mismatches between the declarations and definitions of several functions, as well as an attempt to return a non-const reference to a temporary.
Here is how you can fix the errors:
Error 1: Const correctness
Your GetValueAt definition is const-qualified, but the declaration is not.
Declaration in header file (Int17Matrix3D.h):
cpp
int32_t GetValueAt(int x, int y, int z);
Definition in source file (Int17Matrix3D.cpp):
cpp
int32_t Int17Matrix3D::GetValueAt(int x, int y, int z) const{
To resolve this, you need to make the declaration match the definition by adding the const qualifier:
In Int17Matrix3D.h, update the declaration to:
cpp
int32_t GetValueAt(int x, int y, int z) const;
Error 2: Return type mismatch
The operator[] declaration and definition have mismatching return types. You declared that it should return Int17Matrix3D&, but you are trying to return a Proxy.
Declaration in header file (Int17Matrix3D.h):
cpp
Int17Matrix3D& operator[](int index);
Definition in source file (Int17Matrix3D.cpp):
cpp
Proxy Int17Matrix3D::operator[](int x) {
To fix this, change the return type in the declaration to Proxy:
In Int17Matrix3D.h, update the declaration to:
cpp
Proxy operator[](int index);
Error 3: Returning a temporary as a non-const reference
You are trying to return a temporary int32_t value as a non-const reference from ProxyInt::operator[].
The error you're encountering is due to your attempt to return a temporary int32_t as an int32_t& (lvalue reference) from the GetValueAt function. Here's the function causing the issue:
cpp
int32_t& Int17Matrix3D::GetValueAt(int x, int y, int z) const {
int index = GetIndex(x, y, z);
return ToDecimal(array_, index); // ToDecimal returns a temporary int32_t value
}
There are a few fundamental problems with the code that need to be addressed:
Returning a reference to a temporary is not possible, as temporaries cannot bind to non-const references. The temporary int32_t returned by ToDecimal is destroyed at the end of the expression, so you can’t return it as a reference.
Even if you did return a non-temporary value by reference, it would be a reference to a private int32_t that only exists as a return value from ToDecimal(), so you would end up with a dangling reference, which is undefined behavior.
You returned an int32_t& from a const-qualified function. This should not be done, as it allows the modification of the object's state from a function that promises not to modify the object.
Based on the context in your code, GetValueAt intends to calculate an int32_t value and return it to the caller. However, this function cannot be implemented to return a reference while maintaining your current logic of calculating a value by ToDecimal. You cannot allow modifications to the underlying bit representation of the matrix elements directly, as they are stored with a specialized 17-bit structure.
Here's how you can fix the current error and update the GetValueAt logic:
Change the GetValueAt function to return int32_t instead of int32_t&.
cpp
// Update the declaration in the header file (Int17Matrix3D.h)
int32_t GetValueAt(int x, int y, int z) const;
// Fix the definition in the source file (Int17Matrix3D.cpp)
int32_t Int17Matrix3D::GetValueAt(int x, int y, int z) const {
int index = GetIndex(x, y, z);
return ToDecimal(array_, index);
}
Your compiler errors indicate there are several problems in the test cases:
Proxy classes are forward-declared but not actually defined anywhere.
Returning a local variable's reference from ProxyInt::operator[].
Here are step-by-step instructions to fix the issues:
Define the Proxy and ProxyInt classes before using them.
The Proxy and ProxyInt classes must be fully defined before you can use them in your test cases. You need to move the definitions of Proxy and ProxyInt into the Int17Matrix3D.h header file, or alternatively, define them before you include this header file in Int17Matrix3D_test.cpp.
Fix the ProxyInt::operator[] method.
The current implementation of ProxyInt::operator[] is still attempting to return a reference to a local variable (int32_t value), which will go out of scope immediately after returning.
You need to adjust this method to instead reference an actual element in the Int17Matrix3D::array_. However, as mentioned previously, the internal array is representing values with a custom 17-bit representation. Therefore, simply indexing into this internal array and returning a reference to int32_t will not suffice.
If you intended to provide direct write access to the Int17Matrix3D::array_ elements by indexing, you need to rethink your representation to allow for direct reference access. This will require a change in design. Due to the complexity of such design, and the error-prone nature of bit manipulations, it's recommended to use helper methods to set and retrieve values, like SetAt(int x, int y, int z, int32_t value) and GetAt(int x, int y, int z) instead of trying to use references to manipulate bits directly.
Allocate enough space for your array.
The array allocation in Int17Matrix3D::Int17Matrix3D looks incorrect; you likely need to divide by the number of bits in an int32_t:
cpp
Int17Matrix3D::Int17Matrix3D(int x, int y, int z)
: width_(x), height_(y), depth_(z),
array_(new int32_t[x * y * z * kNumLenght_ / 32 + 1]()) {}
Write getters and setters instead of using overloaded operator[].
To implement the operator[] in such a way that it allows chaining, you need to define your Proxy and ProxyInt classes correctly. The Proxy class must be fully defined before you can use it, and the same goes for ProxyInt. These proxy classes are used to facilitate the chaining for three-dimensional indexing.
Here's a basic example of how you might implement these classes:
cpp
// Forward declarations are not necessary since we're going to define the classes.
// class Proxy;
// class ProxyInt;
// Declaration of Int17Matrix3D is okay as it is, no further edits here.
// Int17Matrix3D implementation...
class ProxyInt {
public:
ProxyInt(Int17Matrix3D& matrix, int x, int y) : matrix_(matrix), x_(x), y_(y) {}
// Returns the actual value for reading
int32_t operator[](int z) const {
return matrix_.GetValueAt(x_, y_, z);
}
// Returns a reference for writing
int32_t& operator[](int z) {
return matrix_.GetValueAt(x_, y_, z);
}
private:
Int17Matrix3D& matrix_;
int x_, y_;
};
class Proxy {
public:
Proxy(Int17Matrix3D& matrix, int x) : matrix_(matrix), x_(x) {}
ProxyInt operator[](int y) const {
return ProxyInt(matrix_, x_, y);
}
private:
Int17Matrix3D& matrix_;
int x_;
};
// You must also update the Proxy return type of Int17Matrix3D::operator[] definition:
Proxy Int17Matrix3D::operator[](int x) {
return Proxy(*this, x);
}
// Your GetValueAt function should return an lvalue reference for assignment.
// Since your array storage is probably in a packed form, consider using a secondary
// array to store references or a structure that on assignment, writes back to the packed data.
int32_t& Int17Matrix3D::GetValueAt(int x, int y, int z) {
// Example implementation of a writable reference getter.
// You need to handle storage and translate (x, y, z) into a 1D index for your backing array.
// This likely won't work directly with your packed bit-format and needs significant changes.
int index = GetIndex(x, y, z);
return array_[index]; // Assume array_ is an unpacked form for illustrative purposes.
}
User
#include
#include "Int17Matrix3D.h"
class ProxyInt {
public:
ProxyInt(Int17Matrix3D& matrix, int x, int y) : matrix_(matrix), x_(x), y_(y) {}
code
// Returns the actual value for reading
int32_t operator[](int z) const {
return matrix_.GetValueAt(x_, y_, z);
}
// Returns a reference for writing
int32_t& operator[](int z) {
return matrix_.GetValueAt(x_, y_, z);
}
private:
Int17Matrix3D& matrix_;
int x_, y_;
};
class Proxy {
public:
Proxy(Int17Matrix3D& matrix, int x) : matrix_(matrix), x_(x) {}
To enable ToDecimal to return a non-temporary value that can be used for reading and assignment through your operator[] implementation, you need to fundamentally change how you're handling the 17-bit values within your Int17Matrix3D class.
The challenge here is that you want to allow read and write access to individual 17-bit values, but they don't align with C++'s built-in types, which makes returning by reference difficult. You can't easily return a reference to a non-temporary, and the bit manipulations necessary mean you can't directly map the indexes to 32-bit chunks of your array_.
Instead, proxy objects are a common solution here, acting as smart references for elements within the custom data structure.
Solution with Proxy Objects
You can create a BitReferenceProxy class that acts as a reference to the actual 17-bit value. Here's an example of how you might start:
cpp
class BitReferenceProxy {
public:
BitReferenceProxy(int32_t* array, int index) : array_(array), index_(index) {}
// Conversion operator to get the value for reading.
operator int32_t() const {
// Your original ToDecimal logic here
int first_bit_index = index_ * 17;
int32_t decimal_value = 0;
int32_t exp = 1;
for (int i = 0; i < 17; ++i) {
if (TakeBit(array_, first_bit_index + i)) {
decimal_value += exp;
}
exp <<= 1;
}
return decimal_value;
}
// Assignment operator for writing.
BitReferenceProxy& operator=(int32_t value) {
// Your original from decimal to bits logic here
int first_bit_index = index_ * 17;
for (int i = 0; i < 17; ++i) {
if (value & (1 << i)) {
SetBit(array_, first_bit_index + i);
} else {
ClearBit(array_, first_bit_index + i);
}
}
return *this;
}
private:
int32_t* array_;
int index_;
// Modified for non-const array access
bool TakeBit(int32_t* value, int bit_position) const {
int array_index = bit_position / 32;
int bit_index = bit_position % 32;
return ((value[array_index] >> bit_index) & 1) != 0;
}
// You may need to adjust these methods to manipulate bits correctly.
void SetBit(int32_t* value, int bit_position){
// Set bit logic...
}
void ClearBit(int32_t* value, int bit_position){
// Clear bit logic...
}
};
// Use BitReferenceProxy in your ProxyInt class
class ProxyInt {
public:
ProxyInt(Int17Matrix3D& matrix, int x, int y) : matrix_(matrix), x_index_(x), y_index_(y) {}
// Return a proxy instead of a reference
BitReferenceProxy operator[](int z) {
int index = /* Calculate the index based on x_index_, y_index_, and z */;
return BitReferenceProxy(matrix_.array_, index);
}
};
User
#include
struct Node {
int data;
int height;
int8_t balance;
Node* left;
Node* right;
};
struct AVL {
Node* top = nullptr;
int height(Node* root) {
if (root == nullptr)
return 0;
return root->height;
}
void UpdateHeightAndBalance(Node* node) {
if (node == nullptr)
return;
To implement the delete operation for an AVL tree with a replacement from the right subtree's minimum, you first need the correct method to find the minimum node. Once you have that, during deletion of a node, you will replace it with its in-order successor (the smallest node in its right subtree) - then you will update the heights and balances starting from the parent of the replaced node upwards to the root, ensuring the tree remains balanced.
You already have a minValueNode method that finds the minimum value node in a given subtree. Now, you need to modify your Delete function accordingly, and then update the heights and balances from the bottom up to balance the tree.
Here's how you might modify the Delete method:
cpp
Node* Delete(Node* root, int key) {
if (root == nullptr) return root;
// Perform standard BST delete
if (key < root->data) {
root->left = Delete(root->left, key);
} else if (key > root->data) {
root->right = Delete(root->right, key);
} else { // root->data == key, delete this node.
if (root->left == nullptr || root->right == nullptr) {
Node* temp = root->left ? root->left : root->right;
if (temp == nullptr) { // No child case
temp = root;
root = nullptr;
} else { // One child case
*root = *temp; // Copy the contents of the non-empty child
}
delete temp;
} else { // Node with two children, get in-order successor.
Node* temp = minValueNode(root->right);
root->data = temp->data; // Copy in-order successor's data
root->right = Delete(root->right, temp->data); // Delete the in-order successor
}
}
if (root == nullptr) return root; // If the tree had only one node and it's deleted.
// Update height and balance the node
root = BalanceTree(root);
// No need to touch the parent of the minimum value node, BalanceTree handles that.
return root;
}
Int17Matrix3D Int17Matrix3D::make_array(int x, int y, int z) {
return Int17Matrix3D(x, y, z);
}
int32_t Int17Matrix3D::GetValueAt(int x, int y, int z) const{
int index = GetIndex(x, y, z);
// Проверьте диапазон для x, y и z перед доступом к массиву
return ToDecimal(array_, index); // Может потребоваться изменить остальную логику
}
for (int i = 0; i < kNumLenght_; ++i) {
if (TakeBit(array_, first_bit_index + i)) {
decimal_value += exp;
}
exp <<= 1;
}
return decimal_value;
}
Int17Matrix3D Int17Matrix3D::operator+(const Int17Matrix3D& other) {
if (this->width_ != other.width_ || this->height_ != other.height_ || this->depth_ != other.depth_) {
throw std::out_of_range("Arrays must be with the same size");
}
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
Int17Matrix3D Int17Matrix3D::operator-(const Int17Matrix3D& other) {
if (this->width_ != other.width_ || this->height_ != other.height_ || this->depth_ != other.depth_) {
throw std::out_of_range("Arrays must be with the same size");
}
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
[ 7%] Building CXX object lib/CMakeFiles/Int17Matrix3D.dir/Int17Matrix3D.cpp.o
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.cpp:52:24: error: out-of-line definition of 'GetValueAt' does not match any declaration in 'Int17Matrix3D'
int32_t Int17Matrix3D::GetValueAt(int x, int y, int z) const{
^~~~~~~~~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:14:11: note: member declaration does not match because it is not const qualified
int32_t GetValueAt(int x, int y, int z);
^ ~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.cpp:58:22: error: return type of out-of-line definition of 'Int17Matrix3D::operator[]' differs from that in the declaration
Proxy Int17Matrix3D::operator[](int x) {
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:16:18: note: previous declaration is here
Int17Matrix3D& operator[](int index);
~~~~~~~~~~~~~~ ^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.cpp:63:12: error: non-const lvalue reference to type 'int32_t' (aka 'int') cannot bind to a temporary of type 'int32_t'
return matrix_.GetValueAt(x_, y_, z);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 errors generated.
make[2]: *** [lib/CMakeFiles/Int17Matrix3D.dir/Int17Matrix3D.cpp.o] Error 1
make[1]: *** [lib/CMakeFiles/Int17Matrix3D.dir/all] Error 2
make: *** [all] Error 2
To resolve this, you will need to reconsider your design for accessing and returning elements from your 3D matrix. Instead of returning a temporary value from GetValueAt, you'll have to return a reference to an actual element:
Change the return type of GetValueAt to int32_t& in both the declaration and the definition.
Update the GetValueAt implementation to return a reference to the actual element in the array_, ensuring correct handling of the internal 17-bit representation and out-of-bounds checking.
Update other member functions if necessary to work with references instead of values. Keep in mind that returning a reference is much more delicate and requires strict ownership and lifecycle management.
After making the necessary changes to your method declarations and definitions, ensure that you maintain consistency between them and properly manage the lifetime of objects to which references are returned. This is critical for avoiding undefined behavior in your code.
Int17Matrix3D Int17Matrix3D::make_array(int x, int y, int z) {
return Int17Matrix3D(x, y, z);
}
int32_t& Int17Matrix3D::GetValueAt(int x, int y, int z) const{
int index = GetIndex(x, y, z);
// Проверьте диапазон для x, y и z перед доступом к массиву
return ToDecimal(array_, index); // Может потребоваться изменить остальную логику
}
for (int i = 0; i < kNumLenght_; ++i) {
if (TakeBit(array_, first_bit_index + i)) {
decimal_value += exp;
}
exp <<= 1;
}
return decimal_value;
}
Int17Matrix3D Int17Matrix3D::operator+(const Int17Matrix3D& other) {
if (this->width_ != other.width_ || this->height_ != other.height_ || this->depth_ != other.depth_) {
throw std::out_of_range("Arrays must be with the same size");
}
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
Int17Matrix3D Int17Matrix3D::operator-(const Int17Matrix3D& other) {
if (this->width_ != other.width_ || this->height_ != other.height_ || this->depth_ != other.depth_) {
throw std::out_of_range("Arrays must be with the same size");
}
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
return stream;
}
[ 7%] Building CXX object lib/CMakeFiles/Int17Matrix3D.dir/Int17Matrix3D.cpp.o
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.cpp:55:12: error: non-const lvalue reference to type 'int32_t' (aka 'int') cannot bind to a temporary of type 'int32_t'
return ToDecimal(array_, index); // Может потребоваться изменить остальную логику
^~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [lib/CMakeFiles/Int17Matrix3D.dir/Int17Matrix3D.cpp.o] Error 1
make[1]: *** [lib/CMakeFi
However, this would make the ProxyInt::operator[] invalid:
cpp
int32_t& ProxyInt::operator[](int z) {
return matrix_.GetValueAt(x_, y_, z); // This would now return a temporary int32_t which cannot be returned as int32_t&
}
Remove the ProxyInt class altogether. The current design of using proxy classes to facilitate 3-dimensional access with operator overloading (operator[][][]) will not work if you cannot return a reference to an actual integer. Instead, work on providing a suitable API to manipulate your custom matrix elements, such as SetAt(int x, int y, int z, int32_t value) and int32_t GetAt(int x, int y, int z) for setting and getting values.
Designing an efficient 3D matrix class with custom bit-width elements is a non-trivial task. You should consider the access patterns and storage layout in detail, and it might be beneficial to refactor the class architecture to provide a consistent and safe public interface.
for (int i = 0; i < kNumLenght_; ++i) {
if (TakeBit(array_, first_bit_index + i)) {
decimal_value += exp;
}
exp <<= 1;
}
return decimal_value;
}
Int17Matrix3D Int17Matrix3D::operator+(const Int17Matrix3D& other) {
if (this->width_ != other.width_ || this->height_ != other.height_ || this->depth_ != other.depth_) {
throw std::out_of_range("Arrays must be with the same size");
}
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
Int17Matrix3D Int17Matrix3D::operator-(const Int17Matrix3D& other) {
if (this->width_ != other.width_ || this->height_ != other.height_ || this->depth_ != other.depth_) {
throw std::out_of_range("Arrays must be with the same size");
}
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
[ 7%] Building CXX object lib/CMakeFiles/Int17Matrix3D.dir/Int17Matrix3D.cpp.o
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.cpp:64:10: warning: reference to stack memory associated with local variable 'value' returned [-Wreturn-stack-address]
return value;
^~~~~
1 warning generated.
[ 14%] Linking CXX static library libInt17Matrix3D.a
[ 14%] Built target Int17Matrix3D
[ 21%] Building CXX object bin/CMakeFiles/labwork5.dir/main.cpp.o
[ 28%] Linking CXX executable labwork5
[ 28%] Built target labwork5
[ 42%] Built target gtest
[ 57%] Built target gtest_main
[ 64%] Building CXX object tests/CMakeFiles/Int17Matrix3D_test.dir/Int17Matrix3D_test.cpp.o
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:21:9: error: calling 'operator[]' with incomplete return type 'Proxy'
matrix[1][1][1] = 5;
^~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:22:19: error: calling 'operator[]' with incomplete return type 'Proxy'
ASSERT_EQ(matrix[1][1][1], 5);
~~~~~~^~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1877:47: note: expanded from macro 'ASSERT_EQ'
#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1861:63: note: expanded from macro 'GTEST_ASSERT_EQ'
ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:36: note: expanded from macro 'ASSERT_PRED_FORMAT2'
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:39: note: expanded from macro 'GTEST_PRED_FORMAT2_'
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT_'
if (const ::testing::AssertionResult gtest_ar = (expression)) \
^~~~~~~~~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:27:9: error: calling 'operator[]' with incomplete return type 'Proxy'
matrix[1][1][1] = 5;
~~~~~~^~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:28:19: error: calling 'operator[]' with incomplete return type 'Proxy'
ASSERT_NE(matrix[1][1][1], 7);
~~~~~~^~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1881:47: note: expanded from macro 'ASSERT_NE'
#define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1863:57: note: expanded from macro 'GTEST_ASSERT_NE'
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:36: note: expanded from macro 'ASSERT_PRED_FORMAT2'
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:39: note: expanded from macro 'GTEST_PRED_FORMAT2_'
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT_'
if (const ::testing::AssertionResult gtest_ar = (expression)) \
^~~~~~~~~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:33:22: error: calling 'operator[]' with incomplete return type 'Proxy'
ASSERT_THROW(matrix[1][1][3] = 5, std::out_of_range);
~~~~~~^~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1761:21: note: expanded from macro 'ASSERT_THROW'
GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)
^~~~~~~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/internal/gtest-internal.h:1423:54: note: expanded from macro 'GTEST_TEST_THROW_'
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
^~~~~~~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/internal/gtest-internal.h:1365:5: note: expanded from macro 'GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_'
statement; \
^~~~~~~~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:39:7: error: calling 'operator[]' with incomplete return type 'Proxy'
arr1[0][0][0] = 10;
~~~~^~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:40:7: error: calling 'operator[]' with incomplete return type 'Proxy'
arr2[0][0][0] = 10;
~~~~^~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:41:7: error: calling 'operator[]' with incomplete return type 'Proxy'
arr2[1][1][1] = 10;
~~~~^~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:42:17: error: calling 'operator[]' with incomplete return type 'Proxy'
ASSERT_EQ(arr1[0][0][0], arr2[0][0][0]);
~~~~^~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1877:47: note: expanded from macro 'ASSERT_EQ'
#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1861:63: note: expanded from macro 'GTEST_ASSERT_EQ'
ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:36: note: expanded from macro 'ASSERT_PRED_FORMAT2'
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:39: note: expanded from macro 'GTEST_PRED_FORMAT2_'
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT_'
if (const ::testing::AssertionResult gtest_ar = (expression)) \
^~~~~~~~~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:42:32: error: calling 'operator[]' with incomplete return type 'Proxy'
ASSERT_EQ(arr1[0][0][0], arr2[0][0][0]);
~~~~^~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1877:53: note: expanded from macro 'ASSERT_EQ'
#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1861:69: note: expanded from macro 'GTEST_ASSERT_EQ'
ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:40: note: expanded from macro 'ASSERT_PRED_FORMAT2'
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:43: note: expanded from macro 'GTEST_PRED_FORMAT2_'
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT_'
if (const ::testing::AssertionResult gtest_ar = (expression)) \
^~~~~~~~~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:43:17: error: calling 'operator[]' with incomplete return type 'Proxy'
ASSERT_EQ(arr1[0][0][0], arr2[1][1][1]);
~~~~^~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1877:47: note: expanded from macro 'ASSERT_EQ'
#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1861:63: note: expanded from macro 'GTEST_ASSERT_EQ'
ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:36: note: expanded from macro 'ASSERT_PRED_FORMAT2'
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:39: note: expanded from macro 'GTEST_PRED_FORMAT2_'
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT_'
if (const ::testing::AssertionResult gtest_ar = (expression)) \
^~~~~~~~~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:43:32: error: calling 'operator[]' with incomplete return type 'Proxy'
ASSERT_EQ(arr1[0][0][0], arr2[1][1][1]);
~~~~^~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1877:53: note: expanded from macro 'ASSERT_EQ'
#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1861:69: note: expanded from macro 'GTEST_ASSERT_EQ'
ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:40: note: expanded from macro 'ASSERT_PRED_FORMAT2'
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:43: note: expanded from macro 'GTEST_PRED_FORMAT2_'
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT_'
if (const ::testing::AssertionResult gtest_ar = (expression)) \
^~~~~~~~~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:49:7: error: calling 'operator[]' with incomplete return type 'Proxy'
arr1[0][0][0] = 1;
~~~~^~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:50:7: error: calling 'operator[]' with incomplete return type 'Proxy'
arr2[0][0][0] = 3;
~~~~^~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:51:17: error: calling 'operator[]' with incomplete return type 'Proxy'
ASSERT_NE(arr1[0][0][0], arr2[0][0][0]);
~~~~^~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1881:47: note: expanded from macro 'ASSERT_NE'
#define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1863:57: note: expanded from macro 'GTEST_ASSERT_NE'
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:36: note: expanded from macro 'ASSERT_PRED_FORMAT2'
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:39: note: expanded from macro 'GTEST_PRED_FORMAT2_'
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT_'
if (const ::testing::AssertionResult gtest_ar = (expression)) \
^~~~~~~~~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:51:32: error: calling 'operator[]' with incomplete return type 'Proxy'
ASSERT_NE(arr1[0][0][0], arr2[0][0][0]);
~~~~^~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1881:53: note: expanded from macro 'ASSERT_NE'
#define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1863:63: note: expanded from macro 'GTEST_ASSERT_NE'
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:40: note: expanded from macro 'ASSERT_PRED_FORMAT2'
GTEST_PRED_FORMAT2_(pred_format, v1, v2, GTEST_FATAL_FAILURE_)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:43: note: expanded from macro 'GTEST_PRED_FORMAT2_'
GTEST_ASSERT_(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT_'
if (const ::testing::AssertionResult gtest_ar = (expression)) \
^~~~~~~~~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:64:20: error: calling 'operator[]' with incomplete return type 'Proxy'
ASSERT_THROW(arr2[1][1][1], std::out_of_range);
~~~~^~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/gtest.h:1761:21: note: expanded from macro 'ASSERT_THROW'
GTEST_TEST_THROW_(statement, expected_exception, GTEST_FATAL_FAILURE_)
^~~~~~~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/internal/gtest-internal.h:1423:54: note: expanded from macro 'GTEST_TEST_THROW_'
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); \
^~~~~~~~~
/Users/alex/labwork5-SPLOIT47/build/_deps/googletest-src/googletest/include/gtest/internal/gtest-internal.h:1365:5: note: expanded from macro 'GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_'
statement; \
^~~~~~~~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:70:7: error: calling 'operator[]' with incomplete return type 'Proxy'
arr1[0][1][2] = 5;
~~~~^~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:71:7: error: calling 'operator[]' with incomplete return type 'Proxy'
arr2[0][0][0] = 3;
~~~~^~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: 'operator[]' declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of 'Proxy'
class Proxy;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [tests/CMakeFiles/Int17Matrix3D_test.dir/Int17Matrix3D_test.cpp.o] Error 1
make[1]: *** [tests/CMakeFiles/Int17Matrix3D_test.dir/all] Error 2
make: *** [all] Error 2
To avoid the issues with using temporary variables and references, you should provide methods to set and get values at specific indices. This will allow your code to handle the bit-wise operations internally rather than returning temporary references:
cpp
int32_t Int17Matrix3D::GetValueAt(int x, int y, int z) const {
// Bounds checking should be done here.
// Calculate the correct index and return the value at that index converted from your bit representation.
}
void Int17Matrix3D::SetValueAt(int x, int y, int z, int32_t value) {
// Bounds checking should be done here.
// Calculate the correct index and set the value at that index correctly using your bit representation.
}
Update your test cases to use the new GetValueAt and SetValueAt methods instead of operator[].
The tests need to be adapted to use the new methods for setting and getting values, as trying to chain operator[] will no longer work correctly with your design.
By following these steps, you should be able to get rid of the compiler errors and proceed with a design that's more equipped to manage the complexity of your 17-bit element 3D matrix.
for (int i = 0; i < kNumLenght_; ++i) {
if (TakeBit(array_, first_bit_index + i)) {
decimal_value += exp;
}
exp <<= 1;
}
return decimal_value;
}
Int17Matrix3D Int17Matrix3D::operator+(const Int17Matrix3D& other) {
if (this->width_ != other.width_ || this->height_ != other.height_ || this->depth_ != other.depth_) {
throw std::out_of_range(“Arrays must be with the same size”);
}
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
Int17Matrix3D Int17Matrix3D::operator-(const Int17Matrix3D& other) {
if (this->width_ != other.width_ || this->height_ != other.height_ || this->depth_ != other.depth_) {
throw std::out_of_range(“Arrays must be with the same size”);
}
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
[ 7%] Building CXX object lib/CMakeFiles/Int17Matrix3D.dir/Int17Matrix3D.cpp.o
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.cpp:64:10: warning: reference to stack memory associated with local variable ‘value’ returned [-Wreturn-stack-address]
return value;
^
1 warning generated.
[ 14%] Linking CXX static library libInt17Matrix3D.a
[ 14%] Built target Int17Matrix3D
[ 21%] Building CXX object bin/CMakeFiles/labwork5.dir/main.cpp.o
[ 28%] Linking CXX executable labwork5
[ 28%] Built target labwork5
[ 42%] Built target gtest
[ 57%] Built target gtest_main
[ 64%] Building CXX object tests/CMakeFiles/Int17Matrix3D_test.dir/Int17Matrix3D_test.cpp.o
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:21:9: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
matrix[1][1][1] = 5;
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:22:19: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
ASSERT_EQ(matrix[1][1][1], 5);
^
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1877:47: note: expanded from macro ‘ASSERT_EQ’
#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1861:63: note: expanded from macro ‘GTEST_ASSERT_EQ’
ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:36: note: expanded from macro ‘ASSERT_PRED_FORMAT2’
GTEST_PRED_FORMAT2(pred_format, v1, v2, GTEST_FATAL_FAILURE)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:39: note: expanded from macro 'GTEST_PRED_FORMAT2’
GTEST_ASSERT(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT’
if (const ::testing::AssertionResult gtest_ar = (expression)) ^~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:27:9: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
matrix[1][1][1] = 5;
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:28:19: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
ASSERT_NE(matrix[1][1][1], 7);
^
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1881:47: note: expanded from macro ‘ASSERT_NE’
#define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1863:57: note: expanded from macro ‘GTEST_ASSERT_NE’
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:36: note: expanded from macro ‘ASSERT_PRED_FORMAT2’
GTEST_PRED_FORMAT2(pred_format, v1, v2, GTEST_FATAL_FAILURE)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:39: note: expanded from macro 'GTEST_PRED_FORMAT2’
GTEST_ASSERT(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT’
if (const ::testing::AssertionResult gtest_ar = (expression)) ^~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:33:22: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
ASSERT_THROW(matrix[1][1][3] = 5, std::out_of_range);
^
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1761:21: note: expanded from macro ‘ASSERT_THROW’
GTEST_TEST_THROW(statement, expected_exception, GTEST_FATAL_FAILURE_)
^
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/internal/gtest-internal.h:1423:54: note: expanded from macro 'GTEST_TEST_THROW’
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); ^
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/internal/gtest-internal.h:1365:5: note: expanded from macro 'GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW’
statement; ^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:39:7: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
arr1[0][0][0] = 10;
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:40:7: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
arr2[0][0][0] = 10;
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:41:7: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
arr2[1][1][1] = 10;
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:42:17: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
ASSERT_EQ(arr1[0][0][0], arr2[0][0][0]);
^
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1877:47: note: expanded from macro ‘ASSERT_EQ’
#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1861:63: note: expanded from macro ‘GTEST_ASSERT_EQ’
ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:36: note: expanded from macro ‘ASSERT_PRED_FORMAT2’
GTEST_PRED_FORMAT2(pred_format, v1, v2, GTEST_FATAL_FAILURE)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:39: note: expanded from macro 'GTEST_PRED_FORMAT2’
GTEST_ASSERT(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT’
if (const ::testing::AssertionResult gtest_ar = (expression)) ^~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:42:32: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
ASSERT_EQ(arr1[0][0][0], arr2[0][0][0]);
^
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1877:53: note: expanded from macro ‘ASSERT_EQ’
#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1861:69: note: expanded from macro ‘GTEST_ASSERT_EQ’
ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:40: note: expanded from macro ‘ASSERT_PRED_FORMAT2’
GTEST_PRED_FORMAT2(pred_format, v1, v2, GTEST_FATAL_FAILURE)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:43: note: expanded from macro 'GTEST_PRED_FORMAT2’
GTEST_ASSERT(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT’
if (const ::testing::AssertionResult gtest_ar = (expression)) ^~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:43:17: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
ASSERT_EQ(arr1[0][0][0], arr2[1][1][1]);
^
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1877:47: note: expanded from macro ‘ASSERT_EQ’
#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1861:63: note: expanded from macro ‘GTEST_ASSERT_EQ’
ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:36: note: expanded from macro ‘ASSERT_PRED_FORMAT2’
GTEST_PRED_FORMAT2(pred_format, v1, v2, GTEST_FATAL_FAILURE)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:39: note: expanded from macro 'GTEST_PRED_FORMAT2’
GTEST_ASSERT(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT’
if (const ::testing::AssertionResult gtest_ar = (expression)) ^~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:43:32: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
ASSERT_EQ(arr1[0][0][0], arr2[1][1][1]);
^
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1877:53: note: expanded from macro ‘ASSERT_EQ’
#define ASSERT_EQ(val1, val2) GTEST_ASSERT_EQ(val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1861:69: note: expanded from macro ‘GTEST_ASSERT_EQ’
ASSERT_PRED_FORMAT2(::testing::internal::EqHelper::Compare, val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:40: note: expanded from macro ‘ASSERT_PRED_FORMAT2’
GTEST_PRED_FORMAT2(pred_format, v1, v2, GTEST_FATAL_FAILURE)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:43: note: expanded from macro 'GTEST_PRED_FORMAT2’
GTEST_ASSERT(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT’
if (const ::testing::AssertionResult gtest_ar = (expression)) ^~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:49:7: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
arr1[0][0][0] = 1;
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:50:7: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
arr2[0][0][0] = 3;
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:51:17: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
ASSERT_NE(arr1[0][0][0], arr2[0][0][0]);
^
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1881:47: note: expanded from macro ‘ASSERT_NE’
#define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1863:57: note: expanded from macro ‘GTEST_ASSERT_NE’
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:36: note: expanded from macro ‘ASSERT_PRED_FORMAT2’
GTEST_PRED_FORMAT2(pred_format, v1, v2, GTEST_FATAL_FAILURE)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:39: note: expanded from macro 'GTEST_PRED_FORMAT2’
GTEST_ASSERT(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT’
if (const ::testing::AssertionResult gtest_ar = (expression)) ^~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:51:32: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
ASSERT_NE(arr1[0][0][0], arr2[0][0][0]);
^
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1881:53: note: expanded from macro ‘ASSERT_NE’
#define ASSERT_NE(val1, val2) GTEST_ASSERT_NE(val1, val2)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1863:63: note: expanded from macro ‘GTEST_ASSERT_NE’
ASSERT_PRED_FORMAT2(::testing::internal::CmpHelperNE, val1, val2)
^~~~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:148:40: note: expanded from macro ‘ASSERT_PRED_FORMAT2’
GTEST_PRED_FORMAT2(pred_format, v1, v2, GTEST_FATAL_FAILURE)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:134:43: note: expanded from macro 'GTEST_PRED_FORMAT2’
GTEST_ASSERT(pred_format(#v1, #v2, v1, v2), on_failure)
^~
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest_pred_impl.h:79:52: note: expanded from macro 'GTEST_ASSERT’
if (const ::testing::AssertionResult gtest_ar = (expression)) ^~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:64:20: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
ASSERT_THROW(arr2[1][1][1], std::out_of_range);
^
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/gtest.h:1761:21: note: expanded from macro ‘ASSERT_THROW’
GTEST_TEST_THROW(statement, expected_exception, GTEST_FATAL_FAILURE_)
^
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/internal/gtest-internal.h:1423:54: note: expanded from macro 'GTEST_TEST_THROW’
GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW_(statement); ^
/Users/alex/labwork5-SPLOIT47/build/deps/googletest-src/googletest/include/gtest/internal/gtest-internal.h:1365:5: note: expanded from macro 'GTEST_SUPPRESS_UNREACHABLE_CODE_WARNING_BELOW’
statement; ^~~
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:70:7: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
arr1[0][1][2] = 5;
~~^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
/Users/alex/labwork5-SPLOIT47/tests/Int17Matrix3D_test.cpp:71:7: error: calling ‘operator[]’ with incomplete return type ‘Proxy’
arr2[0][0][0] = 3;
~~^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:18:9: note: ‘operator[]’ declared here
Proxy operator[](int index);
^
/Users/alex/labwork5-SPLOIT47/lib/Int17Matrix3D.h:3:7: note: forward declaration of ‘Proxy’
class Proxy;
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [tests/CMakeFiles/Int17Matrix3D_test.dir/Int17Matrix3D_test.cpp.o] Error 1
make[1]: *** [tests/CMakeFiles/Int17Matrix3D_test.dir/all] Error 2
make: *** [all] Error 2
мне нужно реализовать именно []
Remember that in its current form, your GetValueAt method should return a reference to a non-temporary storage location. Since you're using a bit-packed representation for the matrix, simply using [] to index into array_ and return a direct reference will not work. You will need a strategy for working with the compact bit representation.
One possible strategy is to use a secondary buffer to hold temporary values that are expanded from the packed bits. When reading a value, you'd unpack it into the buffer and return a reference to that buffer. For writing, you'd use a setter that takes a value, updates the buffer, and then packs the changes back into the bitfield. However, this could be complex and requires careful synchronization between reading, writing, and the lifetime of said buffer.
Alternatively, you might consider representing your matrix as an array of bitfields, for example, using std::vector<std::bitset<17>>, which could make your indexing operations and GetValueAt implementation easier.
The key takeaway is that you need to manage both the representation of the matrix values in memory and provide valid references for reading and writing that integrate neatly with this representation.
for (int i = 0; i < kNumLenght_; ++i) {
if (TakeBit(array_, first_bit_index + i)) {
decimal_value += exp;
}
exp <<= 1;
}
return decimal_value;
}
Int17Matrix3D Int17Matrix3D::operator+(const Int17Matrix3D& other) {
if (this->width_ != other.width_ || this->height_ != other.height_ || this->depth_ != other.depth_) {
throw std::out_of_range("Arrays must be with the same size");
}
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
Int17Matrix3D Int17Matrix3D::operator-(const Int17Matrix3D& other) {
if (this->width_ != other.width_ || this->height_ != other.height_ || this->depth_ != other.depth_) {
throw std::out_of_range("Arrays must be with the same size");
}
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
for (int z = 0; z < this->depth_; ++z) {
for (int y = 0; y < this->height_; ++y) {
for (int x = 0; x < this->width_; ++x) {
int index = this->GetIndex(x, y, z);
как сделать так чтобы ToDecimal возвращала не временное значение
Adjusting operator[] in Int17Matrix3D
You should also adjust your operator[] logic in Int17Matrix3D:
cpp
// In Int17Matrix3D class
ProxyInt operator[](int x) {
ValidateIndex(x); // Make sure to validate x
return ProxyInt(*this, x);
}
By using the BitReferenceProxy class, you are able to use ordinary assignment and equality checking syntax with your custom bit-packed array. This provides a much more natural interface for users of your class, while still allowing you to manage the complexity of the bit manipulations internally.
Furthermore, you will need to ensure appropriate bounds checking and error handling in your methods that calculate indexes and access the array, to prevent out-of-bounds access and other potential issues. The ValidateIndex mentioned in comments is just a placeholder for wherever you might want to implement such a check.
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
char cmd;
AVL tree;
int n;
std::cin >> n;
for (int i = 0; i < n; ++i) {
std::cin >> cmd;
if (cmd == 'A') {
int x;
std::cin >> x;
tree.top = tree.Insert(tree.top, x);
std::cout << (tree.top == nullptr? 0 : tree.top->balance);
if (i < n - 1) {
std::cout << '\n';
}
} else if (cmd == 'D') {
int x;
std::cin >> x;
tree.top = tree.Delete(tree.top, x);
std::cout << (tree.top == nullptr? 0 : tree.top->balance);
if (i < n - 1) {
std::cout << '\n';
}
} else if (cmd == 'C') {
int x;
std::cin >> x;
tree.Exists(tree.top, x) ? std::cout << 'Y' : std::cout << 'N';
if (i < n - 1) {
std::cout << '\n';
}
}
}
}
сделай такое удаление
С заменой на минимум из правого поддерева и правым малым для "удаляемой вершины" а потом балансировкой родителя минимума, который удалили до 26
Notice that after replacing the node to be deleted with its in-order successor (temp->data), the Delete method deletes the in-order successor from the right subtree which triggers re-balancing up the tree. The BalanceTree function is called after every deletion to ensure the subtree rooted at the current node is balanced.
This change should sufficiently incorporate the AVL tree's properties and maintain balance after each deletion. The heights and balances are updated by the UpdateHeightAndBalance method you've already established, and the BalanceTree method is responsible for rotations that may need to occur due to the change in balance.
Finally, this code assumes that you're correctly managing the balance on insertions and other tree modifications using similar balancing logic. If the deletion or insertion is not correctly updating the node heights and balances at every step, the tree may still become unbalanced.