我正在将包含40年数据的文件拆分为单个年份。所以我想做这样的事情:
// get line, convert substring of that line to boost::gregorian::date, and then
// get the year from it. after doing all that,
std::string path = "data_";
path += year // where year is of type boost::gregorian::greg_year
path += ".csv";
当下一行来自"明年"时,创建一个新路径。因此,最后我应该有以下文件:
data_1979.csv
data_1980.csv
data_1981.csv
等。但是如何将boost :: gregorian :: greg_year与字符串连接起来?
答案 0 :(得分:0)
greg_year
的{{1}}将值返回为operator()
。您可以使用unsigned short
将其转换为std::string
。