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

remove operator>> for istream >> setfill(c) #3725

Merged
merged 6 commits into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions stl/inc/iomanip
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,6 @@ template <class _Elem>
struct _Fillobj { // store fill character
_Fillobj(_Elem _Ch) : _Fill(_Ch) {}

template <class _Elem2, class _Traits>
friend basic_istream<_Elem2, _Traits>& operator>>(basic_istream<_Elem2, _Traits>& _Istr, const _Fillobj& _Manip) {
// set fill character in input stream
static_assert(is_same_v<_Elem, _Elem2>, "wrong character type for setfill");

_Istr.fill(_Manip._Fill);
return _Istr;
}

template <class _Elem2, class _Traits>
friend basic_ostream<_Elem2, _Traits>& operator<<(basic_ostream<_Elem2, _Traits>& _Ostr, const _Fillobj& _Manip) {
// set fill character in output stream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -571,18 +571,24 @@ void future_test() {
}
#endif // _M_CEE_PURE

template <typename IoManipIn, typename IoManipOut>
void iomanip_test_impl(IoManipIn in, IoManipOut out) {
template <typename IoManipOut, typename IoManipIn>
void iomanip_test_impl(IoManipOut out, IoManipIn in) {
stringstream ss{};
ss << in;
ss >> out;
ss << out;
ss >> in;
}

template <typename IoManip>
void iomanip_test_impl(IoManip iom) {
iomanip_test_impl(iom, iom);
}

template <typename IoManip>
void iomanip_test_impl_for_setfill(IoManip out) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little weird that this generic function is used only with setfill and includes setfill in its name. I'd call this _output_only or something, describing what it does instead of how it's currently used. This isn't worth resetting testing, though, so don't bother if we don't need to touch something else.

stringstream ss{};
ss << out;
}

void iomanip_test() {
auto sf = setfill('*');
long double money = 123.45;
Expand All @@ -591,7 +597,7 @@ void iomanip_test() {
localtime_s(&time, &t);
string str = "string with \" quotes ";

iomanip_test_impl(sf);
iomanip_test_impl_for_setfill(sf);
iomanip_test_impl(put_money(money), get_money(money));
iomanip_test_impl(put_time(&time, "%c %Z"), get_time(&time, "%c %Z"));
iomanip_test_impl(quoted(str.c_str()), quoted(str));
Expand Down