ericniebler / range-v3

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

with_braced_init_args is failing on older gcc versions #755

Closed ericniebler closed 5 years ago

ericniebler commented 6 years ago

The following code fails to compile with versions of gcc before the 7.x series.

#include <range/v3/core.hpp>
#include <range/v3/algorithm/count.hpp>

int main() {
    return ranges::count({true,false,true,false}, true);
}

The error message is:

prog.cc: In function 'int main()':
prog.cc:5:55: error: call of '(const ranges::v3::with_braced_init_args<ranges::v3::with_braced_init_args<ranges::v3::count_fn> >) (<brace-enclosed initializer list>, bool)' is ambiguous
     return ranges::count({true,false,true,false}, true);
                                                       ^
In file included from /opt/wandbox/range-v3/include/range/v3/utility/iterator_concepts.hpp:23:0,
                 from /opt/wandbox/range-v3/include/range/v3/begin_end.hpp:25,
                 from /opt/wandbox/range-v3/include/range/v3/core.hpp:17,
                 from prog.cc:1:
/opt/wandbox/range-v3/include/range/v3/utility/functional.hpp:889:18: note: candidate: constexpr decltype (declval<const ImplFn&>()(std::move(rng0), (declval<Args>)()...)) ranges::v3::with_braced_init_args<ImplFn>::operator()(std::initializer_list<V0>&&, Args&& ...) const [with V0 = bool; Args = {bool}; ImplFn = ranges::v3::with_braced_init_args<ranges::v3::count_fn>; decltype (declval<const ImplFn&>()(std::move(rng0), (declval<Args>)()...)) = long int]
             auto operator()(std::initializer_list<V0> &&rng0, Args &&...args) const ->
                  ^~~~~~~~
/opt/wandbox/range-v3/include/range/v3/utility/functional.hpp:889:18: note: candidate: constexpr decltype (declval<const ImplFn&>()(std::move(rng0), (declval<Args>)()...)) ranges::v3::with_braced_init_args<ImplFn>::operator()(std::initializer_list<V0>&&, Args&& ...) const [with V0 = bool; Args = {bool}; ImplFn = ranges::v3::count_fn; decltype (declval<const ImplFn&>()(std::move(rng0), (declval<Args>)()...)) = long int]
ericniebler commented 6 years ago

Meta question: do we even care about calling the algorithms with braced init lists? The Ranges TS doesn't bother with handling these.

CaseyCarter commented 6 years ago

If you aren't motivated enough to specify this feature - I know I'm not - then it's probably not useful enough to keep around. Drop in 0.4?

ericniebler commented 5 years ago

None of the algorithms in the v1.0-beta branch use with_braced_init_args, so closing as fixed.