variable type declaration: when using container of pointers

Suppose you have a container of (raw) pointers — very common requirement. Almost anything you do would require an iterator (which works like a double-pointer). The iterator declaration would include the asterisk, like

   map<Account, Book*, less >::iterator

If an algorithm needs a functor (quite common) and if the functor operator() takes an argument, what’s its actual type to replace T in ? Book or Book*

Answer — Book*. In fact, you can safely assume T * is the correct type everywhere. See P90 [[effSTL]]

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s