C++ 后侵位与后推的奇怪行为

C++ 后侵位与后推的奇怪行为,c++,c++11,visual-c++,C++,C++11,Visual C++,代码如下: #include <string> #include <vector> #include <iostream> #include <sstream> #include <iomanip> class Date { public: Date(int year, int month, int day) : year(year), month(month), day(day) {} Date(const Date

代码如下:

#include <string>
#include <vector>
#include <iostream>
#include <sstream>
#include <iomanip>

class Date
{
public:
    Date(int year, int month, int day) : year(year), month(month), day(day) {}
    Date(const Date &d) : year(d.year), month(d.month), day(d.day) {}
    std::string to_string() {
        std::stringstream ss;
        ss << std::setfill('0') << std::setw(4) << year << '-' << std::setw(2) << month << '-' << day;
        return ss.str();
    }
private:
    int year, month, day;
};

int main()
{
    std::vector<Date> vd;
    vd.emplace_back(2017, 1, 13);
    vd.emplace_back(vd[0]);
    std::cout << vd.back().to_string() << "\n";
}
#包括
#包括
#包括
#包括
#包括
上课日期
{
公众:
日期(整年、整月、整日):年(年)、月(月)、日(日){}
日期(const Date&d):年(d.year)、月(d.month)、日(d.day){}
std::字符串到_字符串(){
std::stringstream-ss;

ss“这是VS2015错误吗”我准备打赌是的,这是一个错误:)非常确定这是一个错误。试图找到相关的问答,其中的基本原理是标准,这是不允许的。发现它:是的,这是一个错误:而且:VS2017还打印
2017-01-13
emplace\u back
。该错误可能是由mo的部分实现引起的VS中的DRN C++