ericniebler / range-v3

Range library for C++14/17/20, basis for C++20's std::ranges
Other
4.11k stars 440 forks source link

`std/detail/associated_types.hpp` will break with recent libc++ #1633

Closed ldionne closed 3 years ago

ldionne commented 3 years ago

Those lines won't work anymore with recent versions of libc++:

https://github.com/ericniebler/range-v3/blob/e157199166e20f7f4a730292e212239682a89095/include/std/detail/associated_types.hpp#L267-L272

I haven't done a formal bisect, but I think this is caused by

commit 9f01ac3b3257ab925a2b1229dba19e3eb86a706b
Author: zoecarver <z.zoelec2@gmail.com>
Date:   Tue Apr 20 08:50:11 2021 -0400

    [libcxx] makes `iterator_traits` C++20-aware

    * adds `iterator_traits` specialisation that supports all expected
      member aliases except for `pointer`
    * adds `iterator_traits` specialisations for iterators that meet the
      legacy iterator requirements but might lack multiple member aliases
    * makes pointer `iterator_traits` specialisation require objects

    Depends on D99854.

    Differential Revision: https://reviews.llvm.org/D99855

That change was made as part of our ongoing implementation of Ranges in libc++.

It looks like you are trying to detect whether a specialization of std::iterator_traits refers to the base template or to a full/partial specialization. If so, you could use the presence of the __primary_template member inside std::iterator_traits to detect that in newer versions. Even better would be to not rely on any implementation detail of libc++, however I expect you'll say that you can't live without it.

cc @zoecarver for awareness

ldionne commented 3 years ago

Godbolt reproducer: https://godbolt.org/z/3fdqsY7Yj

I'm about to submit a PR with a fix for this.

ldionne commented 3 years ago

Fixed by PR #1635.

piotrrak commented 2 years ago

-DRANGES_DEEP_STL_INTEGRATION option requires similar fix #1666