c++ioc++20

Why do C++ standards introduce more output methods without input counterparts?


C++20 introduces <format>(and sooner C++23 introduces <print>). I like those methods, and I always try to use std::format when it's supported rather than use a series of <<.

But I notice that this evolution seems to only appear in the output. Why isn't there something like <scan> for input?


Solution

  • std::format and std::print are already quite a big library additions in themselves and I could imagine that the limited resources for the standard committee to consider the addition of additional features didn't allow them to consider an input equivalent at the same time.

    It might also be that the committee wanted to collect more experience with std::format/std::print first before adding an input equivalent or that there are objections to such an addition in principle, in the proposed implementation details or the priority of such an addition.

    I couldn't find any definitive statements pointing towards any of these directions and I have no insider knowledge.

    Anyway, the committee is still considering a std::scan proposal as follow-up to the std::format proposal, see https://github.com/cplusplus/papers/issues/493 for a log of the procedure the proposal has gone through so far. You can also see there polls on design directions, etc. There seems to not have been much activity since 2019, but I am not sure whether this really means anything or not.

    In a reddit thread here from March 2022, Elias Kosunen, one of the authors of the proposal and author of scnlib mentions that there are still some unsure design questions that need to be made sure of before going forward with the proposal, hoping to be able to target C++26, but acknowledging that a farther delay would be preferable to adding a "half-baked" design to the standard.

    As of february 2023, the proposal is still marked "needs-revision", presumably waiting for the author to proceed with it.