From 6ea398c446a0a4058008464b10cc9a89344f8ae9 Mon Sep 17 00:00:00 2001 From: John Maddock Date: Sat, 28 May 2005 11:51:04 +0000 Subject: [PATCH] Make it clear that POD's are not zero initialised. [SVN r29254] --- compressed_pair.htm | 115 ++++++++++++++++++-------------------------- 1 file changed, 46 insertions(+), 69 deletions(-) diff --git a/compressed_pair.htm b/compressed_pair.htm index 6aa1601..4662fc5 100644 --- a/compressed_pair.htm +++ b/compressed_pair.htm @@ -1,30 +1,19 @@ - - - - - -Header - - - - - -

Header -<boost/compressed_pair.hpp>

- -

All of the contents of <boost/compressed_pair.hpp> are -defined inside namespace boost.

- -

The class compressed pair is very similar to std::pair, but if -either of the template arguments are empty classes, then the -"empty base-class optimisation" is applied to compress -the size of the pair.

- -
template <class T1, class T2>
+   
+      Header 
+      
+      
+      
+      
+   
+   
+      

Header <boost/compressed_pair.hpp>

+

All of the contents of <boost/compressed_pair.hpp> are defined inside + namespace boost.

+

The class compressed pair is very similar to std::pair, but if either of the + template arguments are empty classes, then the "empty base-class optimisation" + is applied to compress the size of the pair.

+
template <class T1, class T2>
 class compressed_pair
 {
 public:
@@ -52,47 +41,35 @@ public:
 
 	void swap(compressed_pair& y);
 };
- -

The two members of the pair can be accessed using the member -functions first() and second(). Note that not all member -functions can be instantiated for all template parameter types. -In particular compressed_pair can be instantiated for reference -and array types, however in these cases the range of constructors -that can be used are limited. If types T1 and T2 are the same -type, then there is only one version of the single-argument -constructor, and this constructor initialises both values in the -pair to the passed value.

- -

Note that compressed_pair can not be instantiated if either of -the template arguments is a union type, unless there is compiler -support for boost::is_union, or if boost::is_union is specialised -for the union type.

- -

Finally, a word of caution for Visual C++ 6 users: if either -argument is an empty type, then assigning to that member will -produce memory corruption, unless the empty type has a "do -nothing" assignment operator defined. This is due to a bug -in the way VC6 generates implicit assignment operators.

- -
- -

Revised 08 May 2001

- -

© Copyright boost.org 2000. Permission to copy, use, modify, -sell and distribute this document is granted provided this -copyright notice appears in all copies. This document is provided -"as is" without express or implied warranty, and with -no claim as to its suitability for any purpose.

- -

Based on contributions by Steve Cleary, Beman Dawes, Howard -Hinnant and John Maddock.

- -

Maintained by John -Maddock, the latest version of this file can be found at www.boost.org, and the boost -discussion list at www.yahoogroups.com/list/boost.

- -

 

- +

The two members of the pair can be accessed using the member functions first() + and second(). Note that not all member functions can be instantiated for all + template parameter types. In particular compressed_pair can be instantiated for + reference and array types, however in these cases the range of constructors + that can be used are limited. If types T1 and T2 are the same type, then there + is only one version of the single-argument constructor, and this constructor + initialises both values in the pair to the passed value.

+

Note that if either member is a POD type, then that member is not + zero-initialized by the compressed_pair default constructor: it's up to you to + supply an initial value for these types if you want them to have a default + value.

+

Note that compressed_pair can not be instantiated if either of the template + arguments is a union type, unless there is compiler support for + boost::is_union, or if boost::is_union is specialised for the union type.

+

Finally, a word of caution for Visual C++ 6 users: if either argument is an + empty type, then assigning to that member will produce memory corruption, + unless the empty type has a "do nothing" assignment operator defined. This is + due to a bug in the way VC6 generates implicit assignment operators.

+
+

Revised 08 May 2001

+

© Copyright boost.org 2000. Permission to copy, use, modify, sell and + distribute this document is granted provided this copyright notice appears in + all copies. This document is provided "as is" without express or implied + warranty, and with no claim as to its suitability for any purpose.

+

Based on contributions by Steve Cleary, Beman Dawes, Howard Hinnant and John + Maddock.

+

Maintained by John Maddock, the + latest version of this file can be found at www.boost.org, + and the boost discussion list at www.yahoogroups.com/list/boost.

+

 

+