range-v3 icon indicating copy to clipboard operation
range-v3 copied to clipboard

RANGE_SATISFY_BOOST_RANGE `common_view` does not work because of non-type template parameter

Open huixie90 opened this issue 3 years ago • 6 comments

The attempt in the common.hpp that tries to make common_view to satisfy Boost.Range concept failed. https://github.com/ericniebler/range-v3/blob/0487cca29e352e8f16bbd91fda38e76e39a0ed28/include/range/v3/view/common.hpp#L242

The macro RANGES_SATISFY_BOOST_RANGE was expecting the view only has typename template parameters, https://github.com/ericniebler/range-v3/blob/0487cca29e352e8f16bbd91fda38e76e39a0ed28/include/range/v3/detail/satisfy_boost_range.hpp#L51

but common_view has a non-type template parameter

huixie90 avatar Aug 16 '21 16:08 huixie90

These are all of the views with non-type template parameters that try to use RANGES_SATISFY_BOOST_RANGE (but don't work due to the non-type template parameter)

::ranges::any_view https://github.com/ericniebler/range-v3/blob/0487cca29e352e8f16bbd91fda38e76e39a0ed28/include/range/v3/view/any_view.hpp#L548-L549 https://github.com/ericniebler/range-v3/blob/0487cca29e352e8f16bbd91fda38e76e39a0ed28/include/range/v3/view/any_view.hpp#L691

::ranges::common_view https://github.com/ericniebler/range-v3/blob/0487cca29e352e8f16bbd91fda38e76e39a0ed28/include/range/v3/view/common.hpp#L58-L59 https://github.com/ericniebler/range-v3/blob/0487cca29e352e8f16bbd91fda38e76e39a0ed28/include/range/v3/view/common.hpp#L242

::ranges::cycled_view https://github.com/ericniebler/range-v3/blob/0487cca29e352e8f16bbd91fda38e76e39a0ed28/include/range/v3/view/cycle.hpp#L46-L47 https://github.com/ericniebler/range-v3/blob/0487cca29e352e8f16bbd91fda38e76e39a0ed28/include/range/v3/view/cycle.hpp#L250

::ranges::detail::take_exactly_view_ https://github.com/ericniebler/range-v3/blob/0487cca29e352e8f16bbd91fda38e76e39a0ed28/include/range/v3/view/take_exactly.hpp#L50-L52 https://github.com/ericniebler/range-v3/blob/0487cca29e352e8f16bbd91fda38e76e39a0ed28/include/range/v3/view/take_exactly.hpp#L205

mjbeardsley avatar Aug 17 '21 11:08 mjbeardsley

Thanks for the report. I wonder how this compiles at all. :-/

ericniebler avatar Aug 17 '21 18:08 ericniebler

[..] I wonder how this compiles at all. :-/

cause, (un?)fortunately all current views happen to have non-type args with defaults :)

slymz avatar Aug 17 '21 19:08 slymz

@ericniebler There is a different issue but to do with boost. the satisfy_boost_range.hpp assumes the namespace is called boost https://github.com/ericniebler/range-v3/blob/0487cca29e352e8f16bbd91fda38e76e39a0ed28/include/range/v3/detail/satisfy_boost_range.hpp#L24

But boost allows the users to rename the namespace to something else, e.g. my_boost, and make boost an alias to my_boost https://www.boost.org/doc/libs/1_77_0/tools/bcp/doc/html/index.html

satisfy_boost_range.hpp doesn't work well with that feature because namespace boost won't compile

huixie90 avatar Aug 19 '21 13:08 huixie90

I don't think there is much I can do about that second issue.

ericniebler avatar Aug 19 '21 13:08 ericniebler

I don't think there is much I can do about that second issue.

a build time config, or that along with a macro RANGE_BOOST_NAMESPACE?

slymz avatar Aug 19 '21 20:08 slymz