Namespaces, Typename, References, and Other Conventions

I l @ ve RuBoard

I make quite a few recommendations in this book, and I won't give you guidelines that tell you to do something I don't already do myself . That includes what I do in my own example code throughout this book. I'll also bow to existing practice and modern style, even when it really makes no material difference.

On that note, a word about namespaces: In the code examples, if you see a using-directive at file scope in one example and at function scope in another example a few pages or Items later, there's no deeper reason than that's what felt right and aesthetically pleasing to me for that particular case; for the rationale, turn to Item 40. In the narrative text itself, I've chosen to qualify standard library names with std:: when I want to emphasize that it's the standard facility I'm talking about. Once that's established, I'll generally switch back to using the unqualified name .

When it comes to declaring template parameters, I sometimes come across people who think that writing class instead of typename is old-fashioned, even though there's no functional difference between the two and the standard itself uses class most everywhere. Purely for style, and to emphasize that this book is about today's modern C++, I've switched to using typename instead of class to declare template parameters. The only exception is one place in Item 33, where I quote directly from the standard; the standard says class , so I left it in there.

Unless I call something a "complete program," it's probably not. Remember that the code examples are usually just snippets or partial programs and aren't expected to compile in isolation. You'll usually have to provide some obvious scaffolding to make a complete program out of the snippet shown.

Finally, a word about URLs: On the Web, stuff moves. In particular, stuff I have no control over moves. That makes it a real pain to publish random Web URLs in a print book lest they become out of date before the book makes it to the printer's, never mind after it's been sitting on your desk for five years . When I reference other people's articles or Web sites in this book, I do it via a URL on my own Web site, www.gotw.ca, which I can control and which contains just a straight redirect to the real Web page. If you find that a link printed in this book no longer works, send me e-mail and tell me; I'll update that redirector to point to the new page's location (if I can find the page again) or to say that the page no longer exists (if I can't). Either way, this book's URLs will stay up-to-date despite the rigors of print media in an Internet world. Whew.

I l @ ve RuBoard


More Exceptional C++
More Exceptional C++: 40 New Engineering Puzzles, Programming Problems, and Solutions
ISBN: 020170434X
EAN: 2147483647
Year: 2001
Pages: 118
Authors: Herb Sutter

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net