Billy ONeal
Billy ONeal

Reputation: 106549

What are the advantages and disadvantages of using boost::iterator_facade?

Yep -- the title pretty much sums it up. I've got quite a few types that implement iterator concepts, and I'm wondering if it's worthwhile to pull in this boost header instead of implementing things manually.

So far:

Advantages

Upvotes: 8

Views: 2211

Answers (2)

Paul Michalik
Paul Michalik

Reputation: 4381

boost::iterator_facade does not really reduce "incidence of bugs". It just simplifies the process of writing a standard conformal iterator. A 100% standard conformal iterator might still have bugs :) With regard to the other question:

it's worthwhile to pull in this boost header

Yes, it is, if you're writing iterators of various categories often. This header is quite lightweight, well hm, relatively lightweight, since as anything you pull in from boost also brings the gift of mpl and the preprocessor library. I have found, however, that with VC9 or VC10 this is not as bad as it used to be w.r.t compile times...

Upvotes: 2

Eddy Pronk
Eddy Pronk

Reputation: 6695

If maintaining your own iterator types becomes a burden then switch to boost. They are well specified and tested and less likely to have bugs.

Upvotes: 3

Related Questions