Boost logo

Boost :

From: Ivan Matek (libbooze_at_[hidden])
Date: 2024-04-01 22:28:05


On Mon, Apr 1, 2024 at 7:22 PM Peter Dimov via Boost <boost_at_[hidden]>
wrote:

> Ivan Matek wrote:
> > Or why is
> >
> > #include <boost/foreach.hpp>
> >
> > still available in latest boost?
>
> We should probably do something about that. Unfortunately,
> `#define BOOST_FOREACH(VAR, COL) for(VAR: COL)` doesn't
> work (of course) because as it turns out BOOST_FOREACH
> supports iteration over string literals and std::pair<Iter, Iter>.
>

My mistake, I should have checked all what it supports before bringing it
as an example, as I said last time I used it was 10+y ago and in very
vanilla usecases.
This works with boost for each, but not with language one.
    std::multiset ms{1,2,2,3,3,3,4,4,4,4,5,5,5,5,5};
    auto gimme_five = ms.equal_range(5);
    BOOST_FOREACH(int i, gimme_five) {
        std::print("{}",i);
    };
    for(int i: gimme_five) { // does not compile
        std::print("{}",i);
    }

I would still obviously not do this in prod because despite how cute this
is I would rather have a wrapper that knows to rangify pair<Iter,Iter> than
this, but I must say it is amazing to see this code.

As for other comments: as I have said this has been discussed 1000x, I did
not expect to change anybody's mind, and now I kind of feel bad for wasting
people time since these discussions rarely change anybody's mind, but at
least I think one nice thing is that I fully agree with Arno so there is at
least some benefit to this discussion :)

Just to quickly comment about shared_ptr: as I mentioned I prefer libfmt
over std:: because it keeps bringing up new features I like all the time.
For boost shared_ptr I honestly can not say if this is the case because a)
I avoid shared_ptr as much as I can. b) when I use it std::shared_ptr works
fine for all use cases.
Maybe I am just not that good developer, or I do not work in codebases
where advanced features of boost::shared_ptr are useful...
So if you actually have a reasonable(let's say more than 0.2% of boost
users) usebase that benefits from shared_ptr enhancements over what C++11
has then I am also wrong about this.

In my career only use of boost over std I have ever seen where people have
used boost because it is better is optional(for reference support), in all
other cases it was just there from pre C++11 days(or some other standard,
e.g. variant). I also see unordered as potential future example, but by
chance in most places we used abseil or tessil.

In any case I think that in this entire discussion Arno comment seems as
the best suggestion.
Everybody can use all old libraries but not all libraries are equally
"visible".

Maybe if Vinnie is reading and work on new site is progressing allowing
people to set the base level of their project would be nice when browsing
libraries, for example
I was browsing the website and was not delighted to see Boost.StaticAssert
mentioned here:
https://www.boost.io/doc/user-guide/task-metaprogramming.html
I felt same about TypeTraits, but that library is very large, so not sure
everything from it ended up in std::


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk