Previous section   Next section

Imperfect C++ Practical Solutions for Real-Life Programming
By Matthew Wilson
Table of Contents
Chapter 33.  Multidimensional Arrays


33.6. Multidimensional Arrays: Coda

Hopefully you've had fun with this chapter, and learned some more ways in which C++ has flaws, but also a lot of power to correct them. We've seen that there are dangers in treating any arrays types in precisely the same way as we often (mis)use built-in arrays, but that by using std::fill_n() and the array_size() shim, we can safely write generic code that will work with all array types.

We've also seen how the sophisticated nature of dynamically sized types comes with a performance cost. Both fixed_array and boost::multi_array incur significant performance costs for higher dimensionality, requiring the use of unattractive, nonoperator methods of access. That's just the world we live in; flexibility and facilitating the emulation of built-in syntax can have a performance cost. Providing facilities such as at_unchecked() gives programmers the option of faster code, but at the loss of a more natural syntax. Such is life!


      Previous section   Next section