Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overload operator << for std::wostream doesn't work #86

Closed
aruhan opened this issue Dec 31, 2014 · 1 comment
Closed

Overload operator << for std::wostream doesn't work #86

aruhan opened this issue Dec 31, 2014 · 1 comment

Comments

@aruhan
Copy link
Contributor

aruhan commented Dec 31, 2014

Overload operator << for std::wostream doesn't work.

class Date {
  int year_, month_, day_;
 public:
  Date(int year, int month, int day) : year_(year), month_(month), day_(day) {}

  int year() const { return year_; }
  int month() const { return month_; }
  int day() const { return day_; }

  friend std::wostream &operator<<(std::wostream &os, const Date &d) {
    os << d.year_ << L'-' << d.month_ << L'-' << d.day_;
    return os;
  }
};

std::wstring s = format(L"The date is {0}", Date(2012, 12, 9));
EXPECT_EQ(L"The date is 2012-12-9", s);

RESULT:

>>> error: Value of: s
>>>   Actual: L"The date is 2\00\01\02\0-"
>>>   Expected: L"The date is 2012-12-9"
@vitaut
Copy link
Contributor

vitaut commented Dec 31, 2014

Thanks a lot for the bug report, I'll have a look in the next year =).
Happy New Year!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants