错误:“类”中没有名为“value_type”的类型
error: no type named ‘value_type’ in ‘class
我收到以下编译器错误:
( graph_algorithms.h:59:111: error: no type named ‘value_type’ in ‘class Graph::graph_algorithms<int>::vertex_comparer’
)
这是什么意思?
以下行给了我一大堆编译器错误
std::priority_queue<typename Graph::graph<U>::vertex, typename Graph::graph_algorithms<U>::vertex_comparer> pri_que;
#ifndef GRAPH_ALGORIUHMS_H_
#define GRAPH_ALGORIUHMS_H_
#include <queue>
#include "graph.h"
namespace Graph
{
template <class U>
class graph_algorithms
{
// Forward declarations of
// internal classes
private :
class vertex_comparer;
public :
graph_algorithms(graph<U> &graph) :
m_Graph(graph)
{}
// List of algorithms to perform on graph
typename std::queue<U> &find_key_breadth_first(U key);
// Definition of internal classes
private :
class vertex_comparer
{
public:
bool operator()(typename graph<U>::vertex &v1, typename graph<U>::vertex &v2)
{
return (v1.key() < v2.key()) ? true : false;
}
};
private :
// Private member variables and methods
graph<U> &m_Graph;
std::queue<U> m_Queue;
void breadth_first_search(U key);
};
}
比较类应该是std::priority_queue
模板的第三个参数,第二个参数是一个容器(如std::vector<typename Graph::graph<U>::vertex>
),它将具有value_type
成员。
相关文章:
- 瓦尔格林德:数学函数"Conditional jump or move depends on uninitialised value(s)"
- 使用 [] 运算符时"binding reference of type discards qualifiers"
- 为什么static_assert错误:即使我传递常量"expression must have a constant value"?
- 在 QVector<std::unique_ptr 上使用 std::find<Type>>
- 在类型和包装器之间reinterpret_cast是否安全<Type>?
- 使用 cmake 的 Linux 终端上的"Conversion to non-scalar type is requested"错误
- 控制到达非空函数clang(-Wreturn-type)的末尾
- 为什么我会" void value not ignored as it ought to be"?
- std::unordered_map 类型对象声明期间出现"field has incomplete type"错误
- 方法错误"not all control paths return a value"和方法不返回值
- 将系数存储在头文件的数组中("does not name a type"错误)
- 尝试打开 ifstream 时出现"Incomplete type"错误
- C++/SDL "initial value of reference to a non-const must be an lvalue"
- 将成员函数作为构造函数参数调用时出错 "Variable is not a type name"
- 在"结构提升::enable_if<提升::is_pod<T>,无效>"中没有名为"type"的类型
- 如何修复" State Error (active) E0513 a value of type "const wchar_t *" cannot be assigned to an entity o
- "a value of type " void (exeCallback::*)(int) " cannot be assigned to an entity of type " void (*)(
- cmake -D <var>:<type>=<value> 参数"-D"是什么意思
- 没有用于初始化'value type'的匹配构造函数
- new(size, value) Type[0]返回的指针是否合法,是否可以用来构建数组?