This bugzilla service is closed. All entries have been migrated to

Bug 664

Summary: not all iterator support operator<
Product: Eigen Reporter: facat <felix_du>
Component: SparseAssignee: Nobody <eigen.nobody>
Severity: Unknown CC: chtz
Priority: Normal    
Version: 3.2   
Hardware: x86 - 64-bit   
OS: Linux   

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;

    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:
Comment 2 Nobody 2019-12-04 12:38:45 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to'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: