lundi 27 janvier 2020

Ambiguous != operator for reverse_iterator

When I reverse iterate a map in the following code:

    std::map<Version, VersionBatch>::reverse_iterator versionBatch = self->versionBatches.rbegin();
    for (; versionBatch != self->versionBatches.rend(); versionBatch++) {
        self->batch[batchIndex] = Reference<MasterBatchData>(new MasterBatchData());
        self->batchStatus[batchIndex] = Reference<MasterBatchStatus>(new MasterBatchStatus());
        fBatches.push_back(distributeWorkloadPerVersionBatch(self, batchIndex, cx, request, versionBatch->second));
        batchIndex--;
    }

I got the error from CMake. It seems the reverse_iterator can be interpreted by both utility and iterator, which causes the compiler to confuse. Is there a way to dis-ambiguous this?

Users/ciuser/jenkins/foundationdb-ci.foundationdb.org/workspace/jobs/prb-cmake-macos/fdbserver/RestoreMaster.actor.cpp:276:22: error: use of overloaded operator '!=' is ambiguous (with operand types 'std::map<Version, VersionBatch>::reverse_iterator' (aka 'reverse_iterator<__map_iterator<__tree_iterator<std::__1::__value_type<long long, VersionBatch>, std::__1::__tree_node<std::__1::__value_type<long long, VersionBatch>, void *> *, long> > >') and 'std::__1::map<long long, VersionBatch, std::__1::less<long long>, std::__1::allocator<std::__1::pair<const long long, VersionBatch> > >::reverse_iterator' (aka 'reverse_iterator<__map_iterator<__tree_iterator<std::__1::__value_type<long long, VersionBatch>, std::__1::__tree_node<std::__1::__value_type<long long, VersionBatch>, void *> *, long> > >'))
                        for(;versionBatch != self->versionBatches.rend();versionBatch++) {
                             ~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Library/Developer/CommandLineTools/usr/include/c++/v1/utility:218:1: note: candidate function [with _Tp = std::__1::reverse_iterator<std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::__value_type<long long, VersionBatch>, std::__1::__tree_node<std::__1::__value_type<long long, VersionBatch>, void *> *, long> > >]
operator!=(const _Tp& __x, const _Tp& __y)
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/iterator:710:1: note: candidate function [with _Iter1 = std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::__value_type<long long, VersionBatch>, std::__1::__tree_node<std::__1::__value_type<long long, VersionBatch>, void *> *, long> >, _Iter2 = std::__1::__map_iterator<std::__1::__tree_iterator<std::__1::__value_type<long long, VersionBatch>, std::__1::__tree_node<std::__1::__value_type<long long, VersionBatch>, void *> *, long> >]
operator!=(const reverse_iterator<_Iter1>& __x, const reverse_iterator<_Iter2>& __y)
^
1 error generated.

Thank you very much!

Aucun commentaire:

Enregistrer un commentaire