This bugzilla service is closed. All entries have been migrated to
Bug 1774 - std::cbegin() returns non-const iterator
Summary: std::cbegin() returns non-const iterator
Alias: None
Product: Eigen
Classification: Unclassified
Component: Core - general (show other bugs)
Version: 3.4 (development)
Hardware: All All
: Normal Internal Design
Assignee: Nobody
Keywords: test-needed
Depends on:
Blocks: 3.4
  Show dependency treegraph
Reported: 2019-11-11 15:23 UTC by James Beach
Modified: 2019-12-04 18:54 UTC (History)
4 users (show)


Description James Beach 2019-11-11 15:23:52 UTC
As an example:

    using Op = Eigen::VectorwiseOp<Eigen::Array<int, -1, -1, 0, -1, -1>, 0>;
    using T = Op::const_iterator; // subvector_stl_iterator<const ...>
    using U = decltype(std::declval<const Op&>().cbegin()); // subvector_stl_iterator<const ...>
    using V = decltype(std::cbegin(std::declval<const Op&>())); // subvector_stl_iterator<...>

V should be the same as T, but isn't.
Comment 1 Christoph Hertzberg 2019-11-11 18:11:38 UTC
I guess we can just replace 

    iterator        begin() const;

in VectorwiseOp.h by a const and non-const method (where only the non-const method returns a non-const iterator).

I need to test if that breaks anything, though.
Comment 2 James Beach 2019-11-11 19:10:54 UTC
Yeah, that should fix it. Let me know if there’s anything I can do.
Comment 3 Gael Guennebaud 2019-11-14 10:47:02 UTC
Thank you for the report. Fixed:
Comment 4 Nobody 2019-12-04 18:54:42 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:

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