This bugzilla service is closed. All entries have been migrated to https://gitlab.com/libeigen/eigen

Bug 1774

Summary: std::cbegin() returns non-const iterator
Product: Eigen Reporter: James Beach <james>
Component: Core - generalAssignee: Nobody <eigen.nobody>
Status: RESOLVED FIXED    
Severity: Internal Design CC: chtz, gael.guennebaud, jacob.benoit.1, james
Priority: Normal Keywords: test-needed
Version: 3.4 (development)   
Hardware: All   
OS: All   
Whiteboard:
Bug Depends on:    
Bug Blocks: 814    

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:
https://bitbucket.org/eigen/eigen/commits/5f0ff9f34ddd/
Comment 4 Nobody 2019-12-04 18:54:42 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/1774.