looper@looper-virtual-machine:~/CODE/testcode/Bitset2Vector_then_SHAhash$ g++ -o EXE Bitset2Vector_then_SHAhash.cpp -lssl -lcrypto Bitset2Vector_then_SHAhash.cpp: In function ‘int main()’: Bitset2Vector_then_SHAhash.cpp:51:50: error: conversion from ‘const Eigen::WithFormat<Eigen::Transpose<Eigen::Matrix<double, 1, -1> > >’ to non-scalar type ‘std::string’ {aka ‘std::__cxx11::basic_string<char>’} requested 51 | std::string input = newVec.transpose().format(Eigen::IOFormat(Eigen::FullPrecision, Eigen::DontAlignCols, " ", " ", "", "", "[", "]"));
时间: 2024-04-08 18:29:54 浏览: 188
![ZIP](https://csdnimg.cn/release/download/static_files/pc/images/minetype/ZIP.png)
androidjava源码-android-co:具有Javahttp://159.65.226.217的CatchOpportunity应用
根据您提供的代码片段和错误信息,我注意到在第51行存在一个错误。错误提示指出您尝试将Eigen库中的`WithFormat`类型的对象转换为`std::string`类型,但这是不允许的。
要解决这个问题,您可以将`format`函数应用于Eigen向量对象`newVec.transpose()`,然后将其结果转换为`std::string`类型。您可以使用`.format()`函数的返回类型`std::stringstream`来实现这一点,并将其转换为`std::string`。
以下是一个修改后的代码示例:
```cpp
#include <iostream>
#include <sstream>
#include <Eigen/Dense>
int main() {
Eigen::MatrixXd newVec(1, 5);
newVec << 1, 2, 3, 4, 5;
std::stringstream ss;
ss << newVec.transpose().format(Eigen::IOFormat(Eigen::FullPrecision, Eigen::DontAlignCols, " ", " ", "", "", "[", "]"));
std::string input = ss.str();
std::cout << "Input: " << input << std::endl;
// 其他代码...
return 0;
}
```
请注意,上述代码假设您已正确包含了Eigen库的头文件,并且通过命令行参数`-lssl -lcrypto`指定了链接SSL和Crypto库。
希望这可以帮助您解决问题!如果还有其他问题,请随时提问。
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)