I'm compiling this on macOS using clang/llvm 8.0.0. Compiling for C++14.
#include <fstream>
#include <string>
using namespace std;
basic_fstream<string> open_file(string file);
int main()
{
basic_fstream<string> f = open_file("test");
f.close();
}
basic_fstream<string> open_file(string file) {
basic_fstream<string> f;
f.open(file);
if(!f.is_open()) {
f.clear();
f.open(file, ios_base::out);
f.close();
f.open(file);
}
return f;
}
It produces a long error list but the first is:
implicit instantiation of undefined template 'std::__1::codecvt<std::__1::basic_string<char>, char, __mbstate_t>'
__always_noconv_ = __cv_->always_noconv();