我正在尝试使用自定义比较函数创建一个优先级队列,作为类的数据成员.如果我将队列放在一个类中,代码将无法编译,但是如果它在main
函数内部则可以正常工作:
#include <queue>
#include <vector>
using namespace std;
bool cmp(int x, int y) { return (x > y); }
class A {
public:
private:
priority_queue<int, vector<int>, decltype(cmp) > pq(cmp); // Error at pq(cmp) : function "cmp" is not a type name
};
int main() {
priority_queue<int, vector<int>, decltype(cmp) > pq(cmp); // no error here
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我正在使用Microsoft VS2015获取上述代码.将cmp
函数放在类中是没有区别的.你能解释一下为什么会发生这种情况并为此做出解决方案吗
编辑1:
这行 main
priority_queue<int, vector<int>, decltype(cmp) > pq(cmp); // no error here
Run Code Online (Sandbox Code Playgroud)
确实产生错误,但我的IDE无法检测到它.使用decltype(&cmp)
将消除此错误.
只是好奇心.CuBLAS是用于基本矩阵计算的库.但是,这些计算通常也可以很容易地用普通的Cuda代码编写,而不使用CuBLAS.那么CuBLAS库和你自己的Cuda程序在矩阵计算方面的主要区别是什么?
我有一个包含 4 个节点的 C* 3.11 集群,RF 为 3。在我运行 a 后nodetool repair -full ks1 tb1
,命令窗口显示
Starting repair command #18 (xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx), repairing ks1 with repair options (parallelism: parallel, primary range: false, incremental: false, job threads: 1, ColumnFami
lies: [device], dataCenters: [], hosts: [], # of ranges: 404, pull repair: false)
和
[2018-01-01 01:25:57,730] Repair completed successfully
[2018-01-01 01:25:57,734] Repair command #18 finished in 29 seconds
所以我认为修复运行成功。尽管如此,当我检查时nodetool tablestats ks1.tb1
,命令窗口显示
Percent repaired: 0.0
根据表的不同,结果可能是Percent repaired: 100.0
orPercent repaired: …