Previous section   Next section

Imperfect C++ Practical Solutions for Real-Life Programming
By Matthew Wilson
Table of Contents
Chapter 35.  Properties


35.8. Properties: Coda

It's been a big chapter, the biggest in the book, and I'm sure most of you will have been challenged one way or another. I know when creating these templates I had many brain aches, and coming back to them to document them here was also somewhat bewildering. I had several "why did I do that?" and "I can't remember writing this!" moments.

If you don't comprehend all the complexity in the method property implementations, I'm confident that you will at least appreciate the simplicity in the use of the templates, and to see how useful properties can be. I invite you to experiment with these templates and, fully informed of their strengths and caveats, to use them in your own work.

You should take care to note that it relies on the friendly template technique (see section 16.3), which is a not 100% standards compliant. I'm not playing down the significance of this nonstandard aspect, since you step outside the standard at your (future) peril. But all compilers (see Appendix A) support it apart from the widely respected and most highly standards compliant Comeau compiler in strict mode. And Comeau has recently added a compiler option——friendT—specifically to support this technique in strict mode, so I think we're safely hitching a ride on a train that can't be stopped.[7]

[7] This is a case of caveat emptor. I'm not providing any guarantees, and I do not have inside knowledge of whether the standards body will legitimize friendly templates in C++-0x, merely a strong hunch.

So, stick properties in your imperfect tool kit, and cross your fingers that the standards committee add them as a bona fide feature in the language, such that all this template flummery will eventually be moot.


      Previous section   Next section