[compressed_pair] [hof] [hana] What's the story with compressed_pair?
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? 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? Thanks in advance, Tom
On Wed, May 30, 2018 at 4:10 AM, Tom Westerhout via Boost < boost@lists.boost.org> 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). Louis
On 30/05/2018, Louis Dionne
On Wed, May 30, 2018 at 4:10 AM, Tom Westerhout via Boost < boost@lists.boost.org> 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.
Thanks, Louis.
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).
Could this thread perhaps serve as a start for such a discussion? Tom
Tom Westerhout wrote:
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 suppose that no one has gotten around to do it. :-)
participants (3)
-
Louis Dionne
-
Peter Dimov
-
Tom Westerhout