CRTP и оператор присваивания

У меня есть код, который назначен для класса CRTP, как это:

        IChunkWindow<WindowDerived, IChunk<ChunkDerived>> editWindow = chunkWindow.create(
chunkWindow.getOrigin().getX() + x / ChunkDimensions::MAX_X,
chunkWindow.getOrigin().getZ() + z / ChunkDimensions::MAX_Z,
chunkWindow);

и это класс CRTP:

    template <class Derived, class T>
struct IChunkWindow : public IWindow<IChunkWindow<Derived,T>, T> {

Point3D const& getOrigin() const {
return static_cast<Derived const*>(this)->getOrigin();
}

void setOrigin(Point3D const& origin) {
this->origin = origin;
static_cast<Derived*>(this)->setOrigin(origin);
}
T* getChunk(int cx, int cz) {
return static_cast<Derived*>(this)->getChunk(cx,cz);
}
void setChunk(int cx, int cz, T* ptr) {
static_cast<Derived*>(this)->setChunk(cx,cz,ptr);
}

unsigned char getTerrainBlock(int x, int y, int z) const {
return static_cast<Derived const*>(this)->getTerrainBlock(x,y,z);
}
void setTerrainBlock(int x, int y, int z, unsigned char value) {
static_cast<Derived*>(this)->setTerrainBlock(x,y,z,value);
}
unsigned char getLightBlock(int x, int y, int z) const {
return static_cast<Derived const*>(this)->getLightBlock(x,y,z);
}
void setLightBlock(int x, int y, int z, unsigned char value) {
static_cast<Derived*>(this)->setLightBlock(x,y,z,value);
}
unsigned char getMetaBlock(int x, int y, int z) const {
return static_cast<Derived const*>(this)->getMetaBlock(x,y,z);
}
void setMetaBlock(int x, int y, int z, unsigned char value) {
static_cast<Derived*>(this)->setMetaBlock(x,y,z,value);
}
bool isChunkDirty(int cx, int cz) {
return static_cast<Derived*>(this)->isChunkDirty(cx,cz);
}
bool inBounds(int x, int y, int z) {
return static_cast<Derived*>(this)->inBounds(x,y,z);
}
bool inBounds(int a_cx, int a_cz) {
return static_cast<Derived*>(this)->inBounds(a_cx, a_cz);
}
void insert(int a_x, int a_y, int a_z, unsigned char blockType) {
static_cast<Derived*>(this)->insert(a_x,a_y,a_z,blockType);
}
void remove(int a_x, int a_y, int a_z) {
static_cast<Derived*>(this)->remove(a_x, a_y, a_z);
}
std::vector<BlockPosition> waterPhysics(int a_x, int a_y, int a_z, std::vector<BlockPosition> const& waterSources) {
static_cast<Derived*>(this)->waterPhysics(a_x,a_y,a_z, waterSources);
}

IChunkWindow<Derived, T> create(int a_cx, int a_cz, IChunkWindow<Derived, T> & otherWindow) {
return static_cast<Derived*>(this)->create(a_cx, a_cz, otherWindow);
}

};

Я могу делать вызовы методов на editWindow, но личные данные базового класса (не показаны) являются мусором, поэтому кажется, что назначение не удается. Нужно ли переопределить оператор присваивания в классе IChunkWindow, чтобы это работало?

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector