samedi 28 mars 2015

Error: use of deleted function std::basic_ofstream (OpenCV and C++11) [duplicate]


This question already has an answer here:




I'm trying to import a project that I wrote some time ago under Windows using C++11 and OpenCV but it is giving me troubles and I can't figure out why. It is a MakeFile project and I added a line to enable C++11 support. However, when I'm trying to run "make" or run the project in eclipse I receive the following error (and a few others)



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


My code looks like this:



#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);
...


I think it could be a problem with OpenCV not using C++11, is that possible? How could I fix that? I'm pretty sure this code was working on my windows machine without any problems.


Thank you very much!


Aucun commentaire:

Enregistrer un commentaire