How to define a recursive type?

前端 未结 5 887
孤独总比滥情好
孤独总比滥情好 2021-01-01 14:45

I want to have a list. An entry in the list would store a value as well as an iterator to another entry in the list. How do I define this type? It\'d be something like this,

5条回答
  •  迷失自我
    2021-01-01 15:25

    Use a boost::any, or equivalent, to store the iterator. As iterators tend to be small, the small object optimization will kick in, and the overhead will be low.

提交回复
热议问题