Skip to content

Add std::pair specializations for trivial type traits#64

Open
janzizazizka wants to merge 1 commit intoboostorg:developfrom
janzizazizka:fix/std-pair-partial-specialization-after-instantiation
Open

Add std::pair specializations for trivial type traits#64
janzizazizka wants to merge 1 commit intoboostorg:developfrom
janzizazizka:fix/std-pair-partial-specialization-after-instantiation

Conversation

@janzizazizka
Copy link

Move the std::pair<A,B> partial specializations for the following traits from boost/container/detail/pair.hpp to the headers where the primary templates are defined:

  • is_trivially_destructible (type_traits.hpp)
  • is_trivially_copy_constructible (type_traits.hpp)
  • is_trivially_move_constructible (type_traits.hpp)
  • is_trivially_copy_assignable (type_traits.hpp)
  • is_trivially_move_assignable (type_traits.hpp)
  • has_trivial_destructor_after_move (traits.hpp)

When the specializations live in pair.hpp (included late via flat_map.hpp), GCC diagnoses "partial specialization of '...' after instantiation of '...'" in unity/jumbo builds or any translation unit that implicitly instantiates a trait for std::pair before pair.hpp is included. This is a regression introduced in Boost 1.88/1.90 by commit 9552828 and is the same class of bug as Trac #12534.

The new specializations implement direct member-wise checks (trait::value && trait::value) instead of inheriting from the dtl::pair specializations, so they are self-contained within Boost.Move.

Fixes: boostorg/container#330

Move the std::pair<A,B> partial specializations for the following traits
from boost/container/detail/pair.hpp to the headers where the primary
templates are defined:

  - is_trivially_destructible        (type_traits.hpp)
  - is_trivially_copy_constructible  (type_traits.hpp)
  - is_trivially_move_constructible  (type_traits.hpp)
  - is_trivially_copy_assignable     (type_traits.hpp)
  - is_trivially_move_assignable     (type_traits.hpp)
  - has_trivial_destructor_after_move (traits.hpp)

When the specializations live in pair.hpp (included late via
flat_map.hpp), GCC diagnoses "partial specialization of '...' after
instantiation of '...'" in unity/jumbo builds or any translation unit
that implicitly instantiates a trait for std::pair before pair.hpp is
included.  This is a regression introduced in Boost 1.88/1.90 by commit
9552828 and is the same class of bug as Trac #12534.

The new specializations implement direct member-wise checks
(trait<A>::value && trait<B>::value) instead of inheriting from the
dtl::pair specializations, so they are self-contained within Boost.Move.

Fixes: boostorg/container#330
Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

boost/container/detail/pair.hpp: partial specializations of boost::move_detail traits for std::pair break Unity (jumbo) builds

1 participant