Immutable C++ container class

后端 未结 2 1935
孤街浪徒
孤街浪徒 2021-02-15 00:24

Say that I have a C++ class, Container, that contains some elements of type Element. For various reasons, it is inefficient, undesirable, unnecessary,

2条回答
  •  独厮守ぢ
    2021-02-15 01:01

    As long as your object can provider a conforming const_iterator it doesn't have to have anything else. It should be pretty easy to implement this on your container class.

    (If applicable, look at the Boost.Iterators library; it has iterator_facade and iterator_adaptor classes to help you with the nitty-gritty details)

提交回复
热议问题