Boost logo

Boost Users :

From: Vinnie Falco (vinnie.falco_at_[hidden])
Date: 2022-07-29 13:19:14


On Sun, Jul 24, 2022 at 10:09 AM Vinnie Falco <vinnie.falco_at_[hidden]> wrote:
> I'm considering bumping up the C++ language requirement for Boost.URL
> from C++11 to C++14.

So, here is some fantastic news. My motivation for raising the
language requirement in Boost.URL was for better support for
constexpr, as I wanted to improve the design of its parsing
components. The older design didn't compose very well, didn't allow
for run-time stateful grammars, and was lacking generic abstractions
which used optional, tuple, and variant. The new design relied on
declaring constexpr auto variables and needed a constexpr tuple which
was unavailable in C++11.

I noticed on reddit that there are still reports from users who cannot
move to C++14 for various reasons, see:

<https://www.reddit.com/r/cpp/comments/w6zuo5/c11_or_require_c14/>

I figured out a solution that kept the nice syntax with constexpr but
also worked in C++11, which was to use a "thin tuple" written by
Damian Jarek for beast and modified to be constexpr as an
implementation detail, while using the non-constexpr C++11 "real
tuple" to return results (which doesn't need to be constexpr).

Now at the risk of inviting a ton of bikeshedding and questions like
"why didn't you use Spirit" (please save it for the review which is in
15 days) I was able to throw out an entire page full of annoying
parsing code and replace it with this:

    /** Rule for fragment-part

        @par BNF
        @code
        fragment-part = [ "#" fragment ]

        fragment = *( pchar / "/" / "?" )
        @endcode

        @par Specification
        @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.5"
>3.5. Fragment (rfc3986)</a>
    */
    constexpr auto fragment_part_rule =
        grammar::optional_rule(
            grammar::sequence_rule(
                grammar::char_rule( '#' ),
                    pct_encoded_rule( pchars + '/' + '?' ) ) );

So it seems that I was able to dance my way around the constexpr
limitations. I'm not sure how many more years I'll be able to do this,
but I am happy that I can stay on C++11 for now. Some people think
this is a form of self-torture but I really have not yet felt much
pain from missing out on newer things. Thanks to mp11, variant2, and a
few other Boost "polyfills" C++11 can be quite comfortable.

I think this is great news! Thanks to everyone who provided feedback,
it was very helpful and supportive.

Regards


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net