Boost logo

Boost :

Subject: Re: [boost] [compressed_pair] [hof] [hana] What's the story with compressed_pair?
From: Louis Dionne (ldionne.cpp_at_[hidden])
Date: 2018-05-30 16:55:01

On Wed, May 30, 2018 at 4:10 AM, Tom Westerhout via Boost <
boost_at_[hidden]> wrote:

> Hello!
> It looks like there are at least three different implementations of a
> "std::pair with EBO" in Boost:
> boost/utility/compressed_pair.hpp
> boost/hof/detail/compressed_pair.hpp
> boost/hana/pair.hpp
> Finally, there is also std::tuple which seems to also make use of EBO. I
> need similar functionality for a GSoC project I'm working on this
> year. So I'm wondering, is compressed pair considered a simple
> technicality that should be implemented from scratch every time I need
> it or shall I stick to one of the four mentioned implementations?

If you're able to, I would suggest you use an existing implementation.
They tend to be very tricky to implement, especially the constructor
SFINAE required on them. If you can find one that works for your
use case, just stick to it. That's just my opinion.

> I would much prefer to use Boost.Utility's one, but unfortunately it's
> neither constexpr-friendly nor noexcept-friendly... Is there some reason
> why it cannot be annotated with macros which expand to constexpr and
> noexcept when compiled with C++11 support? Or has no one just gotten
> around to do it?

I think we've just never had this discussion of whether it would be
possible/desirable to share a common implementation of a compressed
pair throughout these new libraries (HOF and Hana).

I'd have to take a look at HOF's and Utility's compressed pairs to see
whether they fulfill the requirements that Hana has (which are mainly
related to compile-time performance).


Boost list run by bdawes at, gregod at, cpdaniel at, john at