Exercises





Exercises

8-0.

Write and test a metaprogram that prints a series of prime numbers using mpl::print. Compare your program to Erwin Unruh's original code at http://www.erwin-unruh.de/primorig.html.

8-1.

Rewrite the assertions in the dimensional analysis code from Chapter 3 to optimize the diagnostics for library users. Analyze the resulting messages as generated by a few different compilers.

8-2.

MPL contains special macros for asserting numeric relations. because, when applicable, they present a much more convenient interface and higher-quality error messages than plain Boolean assertions do. What other category of test might deserve/benefit from a similar approach? Design an interface for handling these cases, and describe the kind of output you'd like to see it generate.

8-3.

Implement the interface you designed in exercise 8-2 using one of the two customized message generation techniques discussed in this chapter.

8-4.

Fix the hand written error reporting in returning_ptr in section 8.3.3 so that the salient information appears in the first line of the diagnostic on GCC.


     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows