Skip to content

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

Open
frederick-vs-ja wants to merge 1 commit intomicrosoft:mainfrom
frederick-vs-ja:mandate-get-put-money
Open

<iomanip>: Add missing Mandates to get_money/put_money#6072
frederick-vs-ja wants to merge 1 commit intomicrosoft:mainfrom
frederick-vs-ja:mandate-get-put-money

Conversation

@frederick-vs-ja
Copy link
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
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

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

Status: Ready To Merge

Development

Successfully merging this pull request may close these issues.

3 participants