нет члена с именем 'value' в 'std :: is_same , std :: vector > - PullRequest
0 голосов
/ 23 марта 2020

Доброе утро всем,

В течение последних нескольких дней у меня была странная проблема, которую я не могу решить:

У меня есть класс Лабиринта, который генерирует лабиринт , Я использую класс Cell для представления каждого квадрата. Все работает правильно (компиляция, выполнение) НО один из моих атрибутов подчеркнут красным цветом со следующим сообщением:

In instantiation of template class 'std::vector<std::vector<Cell, std::allocator<Cell> >, std::allocator<std::vector<Cell, std::allocator<Cell> > > >' no member named 'value' in 'std::is_same<std::vector<Cell, std::allocator<Cell> >, std::vector<Cell, std::allocator<Cell> > > >''.

mesage_in_clion Я использую CLion с CMake на fedora 32.

Вот мои файлы.

maze.h:

#ifndef TESTOPENCV_MAZE_H
#define TESTOPENCV_MAZE_H

#include "cell.h"
#include <vector>
#include <list>
#include <utility>
#include <random>
#include <type_traits>

class Maze {

public:

    Maze(int width, int height);

    void reInit();

    void display(bool pause = false);

    void generate(bool show = false);

    void addFrontier(std::pair<int, int> p, std::list<std::pair<int, int>> &frontier);

    void mark(std::pair<int, int> p, std::list<std::pair<int, int>> &frontier);

    std::list<std::pair<int, int>> neighbors(std::pair<int, int> p);

    static Cell::Direction direction(std::pair<int, int> f, std::pair<int, int> t);

    int get_width();

    int get_height();

    [[nodiscard]] const std::vector<std::vector<Cell>> &get_grid() const;


private:
    std::vector<std::vector<Cell>> grid_;

    int height_;

    int width_;

};

#endif 

cell.h:

#ifndef TESTOPENCV_CELL_H
#define TESTOPENCV_CELL_H

#include <string>

class Cell {
public:
    enum Type {
        EMPTY, MARKED, FRONTIER
    };
    enum Direction {
        N = 1, S = 3, E = 0, W = 2
    };

    int getValue() const { return value_; }

    bool isFrontier(Direction d) const { return frontier[d]; }

    void setValue(int type) { value_ = type; }

    void setFrontier(Direction d, bool state) { frontier[d] = state; }

private:
    int value_ = EMPTY;

    bool frontier[4] = {true, true, true, true};
};


#endif 

Спасибо вам за заранее за вашу помощь.

...