Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Error on iterator_category = int with GCC 13 #4079

@rbrich

Description

@rbrich

We have some non-trivial code featuring C++ concepts, which eventually fails on

std::fill_n(ctx.out(), indent, '\t');

where ctx is fmt::format_context.

The relevant part of error output:

/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:1093:5: note: candidate function template not viable: no known conversion from 'typename iterator_traits<basic_appender<char>>::iterator_category' (aka 'int') to 'std::output_iterator_tag' for 4th argument
    __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value,
    ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:1105:5: note: candidate function template not viable: no known conversion from 'typename iterator_traits<basic_appender<char>>::iterator_category' (aka 'int') to 'std::input_iterator_tag' for 4th argument
    __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value,
    ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:1117:5: note: candidate function template not viable: no known conversion from 'typename iterator_traits<basic_appender<char>>::iterator_category' (aka 'int') to 'std::random_access_iterator_tag' for 4th argument
    __fill_n_a(_OutputIterator __first, _Size __n, const _Tp& __value,
    ^
/usr/lib/gcc/x86_64-linux-gnu/13/../../../../include/c++/13/bits/stl_algobase.h:1086:5: note: candidate template ignored: could not match '_Safe_iterator' against 'basic_appender'
    __fill_n_a(const ::__gnu_debug::_Safe_iterator<_Ite, _Seq, _Cat>& __first,

I may be able to write a minimal reproducer, but the issue seems obvious:

using iterator_category = int;

Changing this to using iterator_category = std::output_iterator_tag; fixed the errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions