Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • eigen eigen
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 653
    • Issues 653
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Custom issue tracker
    • Custom issue tracker
  • Merge requests 19
    • Merge requests 19
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • libeigen
  • eigeneigen
  • Issues
  • #1619
Closed
Open
Created Dec 04, 2019 by Eigen Bugzilla@eigenbzReporter

const_iterator vs iterator compilation error

Submitted by w.h..@..il.com

Assigned to Nobody

Link to original bugzilla bug (#1619)
Version: 3.4 (development)

Description

I was experimenting with the new STL-compatible iterator capability using VS 2017. The following code snippet compiles correctly:

const int n = 6;
typedef Eigen::VectorXd V;
V v(n);
v << 1, 4, 6, 17, 33, 8;
cout << v.transpose() << endl;
for (V::iterator it = v.begin(); it != v.end(); ++it)
cout << *it << ", ";

However, if I replace V::iterator with V::const_iterator, VS produces these
compilation errors:

1>------ Build started: Project: eigenXTests, Configuration: Debug x64 ------
1>eigenXTests.cpp
1>c:\wgreene\tests\c++\vs2017tests\eigenxtests\eigenxtests.cpp(18): error C2440: 'initializing': cannot convert from 'Eigen::internal::pointer_based_stl_iterator<Derived>' to 'Eigen::internal::pointer_based_stl_iterator<const Derived>'
1> with
1> [
1> Derived=Eigen::Matrix<double,-1,1,0,-1,1>
1> ]
1>c:\wgreene\tests\c++\vs2017tests\eigenxtests\eigenxtests.cpp(18): note: No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\wgreene\tests\c++\vs2017tests\eigenxtests\eigenxtests.cpp(18): error C2679: binary '!=': no operator found which takes a right-hand operand of type 'Eigen::internal::pointer_based_stl_iterator<Derived>' (or there is no acceptable conversion)
1> with
1> [
1> Derived=Eigen::Matrix<double,-1,1,0,-1,1>
1> ]
1>c:\wgreene\src\eigen\eigen-3.3.x\eigen\src\core\stliterators.h(96): note: could be 'bool Eigen::internal::pointer_based_stl_iterator<const Derived>::operator !=(const Eigen::internal::pointer_based_stl_iterator<const Derived> &)'
1> with
1> [
1> Derived=Eigen::Matrix<double,-1,1,0,-1,1>
1> ]
1>c:\wgreene\tests\c++\vs2017tests\eigenxtests\eigenxtests.cpp(18): note: while trying to match the argument list '(Eigen::internal::pointer_based_stl_iterator<const Derived>, Eigen::internal::pointer_based_stl_iterator<Derived>)'
1> with
1> [
1> Derived=Eigen::Matrix<double,-1,1,0,-1,1>
1> ]
1>Done building project "eigenXTests.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Blocking

#814 (closed)

Edited Dec 05, 2019 by Eigen Bugzilla
Assignee
Assign to
Time tracking