Skip to content

ustring: Simplify format() using C++17 fold expression, test output, Stringify cleanups

Daniel Boles requested to merge wip/dboles/ustring_format_fold_and_test into master
commit fbe267d6b84ccec41ff3440e9260b471d27af9ad
Author: Daniel Boles <dboles@src.gnome.org>
Date:   Sun Oct 14 13:32:18 2018 +0100

    ustring: Use C++17 fold expr. instead of recursion
    
    Instead of having to manually recurse in order to stream every element
    in the parameter pack, use the new fold expressions, by streaming a
    binary left fold of operator, - to do the same thing in far fewer lines.
commit a485da170962743f29e4a18d5d8745874042d662
Author: Daniel Boles <dboles@src.gnome.org>
Date:   Sun Oct 14 13:33:01 2018 +0100

    tests/glibmm_ustring_format: Test output, iomanips
    
    We only tested here whether single arguments got formatted without
    throwing exceptions, but not whether they got formatted into the
    expected output or combinations of multiple types and I/O manipulators.
    
    This adds a test for that, so we at least have something to ensure that
    things are working correctly, e.g. if refactoring format() as I just did

edit: added a few unrelated cleanups. I can split these to another MR if you want; I just got lazy.

commit 3b3d656c4eb176cca33069aa53b4f4a555e958de (HEAD -> wip/dboles/ustring_format_fold_and_test, origin/wip/dboles/ustring_format_fold_and_test)
Author: Daniel Boles <dboles@src.gnome.org>
Date:   Sun Oct 14 14:36:10 2018 +0100

    ustring: Remove useless alternative Stringify ctor
    
    This can never be called, because we explicitly specialise Stringify for
    const char*, so that specialisation will always be used instead of this.

commit c4de7256ad414e31c00cafda3b98ab7757188f0e
Author: Daniel Boles <dboles@src.gnome.org>
Date:   Sun Oct 14 14:27:36 2018 +0100

    ustring: Avoid un(necessary|clear) ptr @ Stringify
    
    Rather than storing a pointer in the temporary Stringify objects, we can
    instead store a reference, which is clearer about it being non-optional
    and makes for nicer syntax. Then we return that and use operator& when
    forwarding it to compose_private() in the std::initializer_list, since
    containers can't hold references, so we do need a pointer there. Unless:
    
    We could perhaps go a step further and make that an initializer_list of
    std::reference_wrapper, avoiding pointers altogether while probably not
    incurring overhead as it is a simple wrapper, but that's one for later.

commit f6e3298e4e51d1e3ca4c4847cc26070847a7d2a6
Author: Daniel Boles <dboles@src.gnome.org>
Date:   Sun Oct 14 14:16:20 2018 +0100

    ustring: Make 1 Stringify member const like others
    
    This was the only specialisation of Stringify in which the member
    string_ was not already const. Make it so.
Edited by Daniel Boles

Merge request reports