Skip to content

<iomanip>: Add missing Mandates to get_money/put_money#6072

Merged
StephanTLavavej merged 1 commit into
microsoft:mainfrom
frederick-vs-ja:mandate-get-put-money
Feb 11, 2026
Merged

<iomanip>: Add missing Mandates to get_money/put_money#6072
StephanTLavavej merged 1 commit into
microsoft:mainfrom
frederick-vs-ja:mandate-get-put-money

Conversation

@frederick-vs-ja
Copy link
Copy Markdown
Contributor

MSVC STL currently accepts the following example which violates [ext.manip]/2 and [ext.manip]/5. Godbolt link.

#include <functional>
#include <iomanip>
#include <istream>
#include <ostream>
#include <string>

void test(std::istream& is, std::ostream& os) {
    struct xstr : std:: string {};
    xstr x;

    is >> std::get_money(x);
    os << std::put_money(x);

    long double y{};
    auto ref_y = std::ref(y);
    is >> std::get_money(ref_y);
    os << std::put_money(ref_y);
}

We need to require that _Money is exactly long double or basic_string, not another convertible/deducible type.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner February 5, 2026 06:53
@github-project-automation github-project-automation Bot moved this to Initial Review in STL Code Reviews Feb 5, 2026
@StephanTLavavej StephanTLavavej added the bug Something isn't working label Feb 5, 2026
@StephanTLavavej StephanTLavavej moved this from Initial Review to Ready To Merge in STL Code Reviews Feb 5, 2026
@achabense
Copy link
Copy Markdown
Contributor

Mandates: The type moneyT is either long double or a specialization of the basic_string template ([strings]).

(No change requested) Though this is mandated by the standard, I'd say the change will fail a lot of code (which should have failed in the past). A lot of non-serious projects use const char*, double and integers etc.
https://github.com/search?q=put_money%28+lang%3AC%2B%2B&type=code

@StephanTLavavej StephanTLavavej moved this from Ready To Merge to Merging in STL Code Reviews Feb 9, 2026
@StephanTLavavej
Copy link
Copy Markdown
Member

I'm mirroring this to the MSVC-internal repo. Please notify me if any further changes are pushed, otherwise no action is required.

@StephanTLavavej StephanTLavavej merged commit 60147bb into microsoft:main Feb 11, 2026
45 checks passed
@github-project-automation github-project-automation Bot moved this from Merging to Done in STL Code Reviews Feb 11, 2026
@StephanTLavavej
Copy link
Copy Markdown
Member

Thanks for noticing and fixing this missing enforcement! 🤑 💸 💵

@frederick-vs-ja frederick-vs-ja deleted the mandate-get-put-money branch February 12, 2026 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants