错误:使用已删除的函数std :: basic_ofstream(OpenCV和C ++ 11)

时间:2015-03-28 17:31:48

标签: c++ eclipse opencv c++11 makefile-project

我正在尝试导入我之前在Windows下使用C ++ 11和OpenCV编写的项目,但它给我带来了麻烦,我无法弄清楚原因。这是一个MakeFile项目,我添加了一行来启用C ++ 11支持。但是,当我试图在eclipse中运行“make”或运行项目时,我收到以下错误(以及其他一些错误)

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机器上运行没有任何问题。

非常感谢!

1 个答案:

答案 0 :(得分:8)

该行

save_file = std::ofstream(path_temp, std::fstream::app);

应该调用move operator=,因为rhs是prvalue。所以原则上应该有效。但是,gcc中似乎存在一个错误&lt; 5.0实现,

Why can't I move std::ofstream?

相关问题