This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen
Bug 664 - not all iterator support operator<
Summary: not all iterator support operator<
Status: RESOLVED FIXED
Alias: None
Product: Eigen
Classification: Unclassified
Component: Sparse (show other bugs)
Version: 3.2
Hardware: x86 - 64-bit Linux
: Normal Unknown
Assignee: Nobody
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-09-27 09:32 UTC by facat
Modified: 2019-12-04 12:38 UTC (History)
1 user (show)



Attachments

Description facat 2013-09-27 09:32:16 UTC
Recently I compiled my program with Eigen 3.2 stable and encouterd an error as follow:

error: no match for ‘operator<’ (operand types are ‘const std::_List_iterator<Eigen::Triplet<double> >’ and ‘const std::_List_iterator<Eigen::Triplet<double> >’)

This is caused by comparing "begin" end "end" in function set_from_triplets in SparseMatrix.h

"begin" and "end" are two iterator variable. This error is due the fact that iterator of std::list doesn't support < operation. This bug was introduced by the 9e8ce09 commit for "Fix setFromTripplet with empty inputs". We know that many containers support iterator, but not all their iterators support operator<. std::list is the case. To my best knowledge, all iterators support operator!=. 
I think operator!= is more general to check if a container is empty.

The example below can reprduce the error

///////////////////////////////////
#include <iostream>

#include <Eigen/Sparse>
#include <list>

using namespace std;

int main()
{
    Eigen::SparseMatrix<double> mat(3,3);
    std::list<Eigen::Triplet<double> > t;
    t.push_back(
    Eigen::Triplet<double>(0,0,1)
    );

    mat.setFromTriplets(t.begin(),t.end());
    return 0;
}

////////////////////////////////

I compiled my code under linux Mint 64bit with gcc 4.8.1.
Comment 1 Christoph Hertzberg 2013-10-16 13:41:56 UTC
Fixed and backported to 3.2 here:
https://bitbucket.org/eigen/eigen/commits/961ac1984b0fd685bb9becc18674008897562d28
Comment 2 Nobody 2019-12-04 12:38:45 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to gitlab.com's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.com/libeigen/eigen/issues/664.

Note You need to log in before you can comment on or make changes to this bug.