Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

C/C++

Living By the Rules: Part II


Conclusion

I've skipped over some of the details of most of these changes. I don't plan on addressing these changes systematically—you'll undoubtedly be seeing books about the new language Standard as it becomes more complete and more stable. In the meantime, I'll continue to highlight the changes as they're approved, which will be once every six months.

Notes

  1. The nearly final draft is available at www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1836.pdf. The special math functions, including such things as elliptic integrals of the first kind and hermite polynomials, were felt to be too complex and too narrowly focused for the Standard.
  2. A call wrapper is one form of what is known generically as a "function object." A call wrapper type has a function call operator that forwards to a function object held by the call wrapper. One example of a call wrapper is the object returned by std::mem_fun: It holds a pointer to member function. It has a function call operator that can be called with ordinary function call syntax, and forwards to the pointer to member function, treating its first argument as the object to apply the pointer to.
  3. Of course, to use these new library facilities you'll need a good reference book. My completely unbiased recommendation is my book, The C++ Standard Library Extensions: A Tutorial and Reference, which will be published this summer by Addison-Wesley.
  4. This example is attributed to Hyman Rosen in the paper that first proposed changing this rule.
  5. This example puts the default constructor in the initializer list, but you can use any valid constructor invocation. When you do this, you can't put anything else in the initializer list. You have to do all of the relevant initialization in the target constructor, and then the body of the constructor you're defining can do whatever else needs to be done.
  6. Unfortunately, this change will be interpreted as an endorsement of writing one-off loops instead of algorithms. In general, instead of creating named iterator objects, you should write template functions and call them with the temporary objects returned by begin() and end().
  7. Or eight, depending on whether you count the version that uses "<" as separate from the version that uses a user-supplied predicate.
  8. Epsilon is the smallest value that can be added to 1.0 to produce a different value.
  9. You can also have ordinary macro arguments before the ellipsis.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.