Is comparison of const_iterator with iterator well-defined?

前端 未结 3 994
清歌不尽
清歌不尽 2020-12-15 15:50

Consider the following code:

#include 
#include 

int main()
{
    std::vector vec{1,2,3,5};
    for(auto it=vec.cbe         


        
3条回答
  •  再見小時候
    2020-12-15 16:39

    See §23.2.1, Table 96:

    X::iterator
    

    [...]

    any iterator category that meets the forward iterator requirements.

    convertible to X::const_iterator

    So, yes, it is well-defined.

提交回复
热议问题