When using the list class of Example 10.17, the typical C++ programmer will use a pointer type for generic parameter V, so that list_nodes point to the elements of the list. An alternative...



When using the list class of Example 10.17, the typical C++ programmer


will use a pointer type for generic parameter V, so that list_nodes point


to the elements of the list. An alternative implementation would include


next and prev pointers for the list within the elements themselves—


typically by arranging for the element type to inherit from something like


the gp_list_node class of Example 10.14. The result is sometimes called


an intrusive list.


(a) Explain how you might build intrusive lists in C++ without requiring users to pepper their code with explicit type casts. Hint: given


multiple inheritance, you will probably need to determine, for each


concrete element type, the offset within the representation of the type


at which the next and prev pointers appear. For further ideas, search


for information on the boost::intrusive::list class of the popular Boost library.


(b) Discuss the relative advantages and disadvantages of intrusive and


non-intrusive lists.

Nov 20, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here