• Modern C++

    From Student Project@21:1/5 to All on Fri Nov 29 05:49:38 2024
    XPost: alt.comp.lang.c++.misc

    Which compiler is currently able to compile this two code snippets:

    std::vector<int> v = {1, 2, 3, 4, 5};
    std::println("{}", v);


    Suppose you want it to be centered in a line of 40 characters, with
    underscore characters around it:

    std::vector<int> v = {1, 2, 3, 4, 5};
    std::println("{:_^40}", v);
    // ____________[1, 2, 3, 4, 5]_____________


    Source: <https://isocpp.org/blog/2024/11/having-fun-with-modern-cpp-daniel-lemire>

    Thank you for reading this and possible solution.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From red floyd@21:1/5 to wij on Fri Nov 29 12:27:06 2024
    On 11/28/2024 11:21 PM, wij wrote:
    On Fri, 2024-11-29 at 05:49 +0000, Student Project wrote:
    Which compiler is currently able to compile this two code snippets:

    std::vector<int> v = {1, 2, 3, 4, 5};
    std::println("{}", v);

    g++ 13.2.1 does not compile.


    Suppose you want it to be centered in a line of 40 characters, with
    underscore characters around it:

    std::vector<int> v = {1, 2, 3, 4, 5};
    std::println("{:_^40}", v);
    // ____________[1, 2, 3, 4, 5]_____________


    Source:
    <https://isocpp.org/blog/2024/11/having-fun-with-modern-cpp-daniel-lemire> >>
    Thank you for reading this and possible solution.


    IMO, such funciion is unnecessary, esp. inventing it to add burden to programmer.

    There are lots of I/O formatting problems.
    The basic solution is writing your own 'printf', or atoi,... (all are simple)

    There are already lots of printf examples for students, why this 'new' one?


    He's asking us to do his homework.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)