Error: use of deleted function std::basic_ofstream (OpenCV and C++11)
Error: use of deleted function std::basic_ofstream (OpenCV and C++11)
我正在尝试导入我之前在 Windows 下使用 C++11 和 OpenCV 编写的项目,但它给我带来了麻烦,我不明白为什么。这是一个 MakeFile 项目,我添加了一行以启用 C++11 支持。但是,当我尝试 运行 "make" 或 运行 eclipse 中的项目时,我收到以下错误(以及其他一些错误)
use of deleted function ‘std::basic_filebuf<char>& std::basic_filebuf<char>::operator=(const std::basic_filebuf<char>&)’ FacadeLabelingV2 line 599, external location: /usr/include/c++/4.8/fstream
我的代码如下所示:
#ifndef _FILEUTIL_CPP_
#define _FILEUTIL_CPP_
#include "Configuration.h"
#include "Utilities.cpp"
#include <iostream>
#include <fstream>
static void saveFeatures(const std::pair<cv::Mat, cv::Mat>& features, const Configuration& config, bool training, bool append, int counter = 0){
string prefix;
if (training) {
prefix = "train";
} else {
prefix = "test";
}
std::string directory = config.dir_classifiers + config.name_of_run;
std::ofstream save_file;
std::string counter_appendix = std::to_string(counter / 50);
std::string path_temp = directory + prefix + "_features" + counter_appendix + ".txt";
if (append){
save_file = std::ofstream(path_temp, std::fstream::app);
...
我认为这可能是 OpenCV 不使用 C++11 的问题,这可能吗?我该如何解决?我很确定这段代码在我的 windows 机器上运行没有任何问题。
非常感谢!
行
save_file = std::ofstream(path_temp, std::fstream::app);
应该调用移动 operator=
,因为 rhs 是纯右值。所以原则上它应该工作。但是,在 gcc < 5.0 的实现中似乎存在一个错误,
我正在尝试导入我之前在 Windows 下使用 C++11 和 OpenCV 编写的项目,但它给我带来了麻烦,我不明白为什么。这是一个 MakeFile 项目,我添加了一行以启用 C++11 支持。但是,当我尝试 运行 "make" 或 运行 eclipse 中的项目时,我收到以下错误(以及其他一些错误)
use of deleted function ‘std::basic_filebuf<char>& std::basic_filebuf<char>::operator=(const std::basic_filebuf<char>&)’ FacadeLabelingV2 line 599, external location: /usr/include/c++/4.8/fstream
我的代码如下所示:
#ifndef _FILEUTIL_CPP_
#define _FILEUTIL_CPP_
#include "Configuration.h"
#include "Utilities.cpp"
#include <iostream>
#include <fstream>
static void saveFeatures(const std::pair<cv::Mat, cv::Mat>& features, const Configuration& config, bool training, bool append, int counter = 0){
string prefix;
if (training) {
prefix = "train";
} else {
prefix = "test";
}
std::string directory = config.dir_classifiers + config.name_of_run;
std::ofstream save_file;
std::string counter_appendix = std::to_string(counter / 50);
std::string path_temp = directory + prefix + "_features" + counter_appendix + ".txt";
if (append){
save_file = std::ofstream(path_temp, std::fstream::app);
...
我认为这可能是 OpenCV 不使用 C++11 的问题,这可能吗?我该如何解决?我很确定这段代码在我的 windows 机器上运行没有任何问题。
非常感谢!
行
save_file = std::ofstream(path_temp, std::fstream::app);
应该调用移动 operator=
,因为 rhs 是纯右值。所以原则上它应该工作。但是,在 gcc < 5.0 的实现中似乎存在一个错误,