Obtaining const_iterator from iterator

前端 未结 4 1129
余生分开走
余生分开走 2020-12-16 16:24

Is there a metafunction f that maps an iterator to its corresponding const_iterator?

I.e. f::ite

4条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-16 16:42

    I think a general solution to your problem (and one that would also be portable is not possible). At least i cannot imagine one :-).

    The difficult problem here is that the container defines the const_iterator type. To get to the const_iterator type for the container you have to determine the container type.

    However if you start with the iterator type of the container as metafunction parameter it is not possible to retrieve the type of the container.

    For known T(s) what you want can be achieved however...

提交回复
热议问题