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

detail::test_cardinality requires access to privately inherited class #1614

Open ahmed-moubtahij opened 3 years ago

ahmed-moubtahij commented 3 years ago

https://github.com/ericniebler/range-v3/blob/81b6d3f1bf636395645cc2ed245a5947c404a4b2/include/range/v3/range/traits.hpp#L125

https://godbolt.org/z/48M85o

In using a views algorithm here (zip_with) I get the following error message:

<source>:53:62:   required from here
/opt/compiler-explorer/libs/rangesv3/0.11.0/include/range/v3/range/traits.hpp:125:60: error: 'std::array<int, 3>' is an inaccessible base of 'DataPoint<int, 3>'
  125 |                           decltype(detail::test_cardinality(
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~^
  126 |                               static_cast<uncvref_t<Rng> *>(nullptr))),
      |                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Needing to access a privately inherited class feels a bit intrusive. It works if I specialize ranges::range_cardinality (uncomment code on lines 41 to 50).