| 1 | <html> |
|---|
| 2 | <head> |
|---|
| 3 | <title>Header </title> |
|---|
| 4 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
|---|
| 5 | <meta name="Template" content="C:\PROGRAM FILES\MICROSOFT OFFICE\OFFICE\html.dot"> |
|---|
| 6 | <meta name="GENERATOR" content="Microsoft FrontPage Express 2.0"> |
|---|
| 7 | <boostcompressed_pair.hpp> |
|---|
| 8 | </head> |
|---|
| 9 | <body bgcolor="#ffffff" text="#000000" link="#0000ff" vlink="#800080"> |
|---|
| 10 | <h2><img src="../../boost.png" width="276" height="86">Header <<a href="../../boost/detail/compressed_pair.hpp">boost/compressed_pair.hpp</a>></h2> |
|---|
| 11 | <p>All of the contents of <boost/compressed_pair.hpp> are defined inside |
|---|
| 12 | namespace boost.</p> |
|---|
| 13 | <p>The class compressed pair is very similar to std::pair, but if either of the |
|---|
| 14 | template arguments are empty classes, then the "empty base-class optimisation" |
|---|
| 15 | is applied to compress the size of the pair.</p> |
|---|
| 16 | <pre>template <class T1, class T2> |
|---|
| 17 | class compressed_pair |
|---|
| 18 | { |
|---|
| 19 | public: |
|---|
| 20 | typedef T1 first_type; |
|---|
| 21 | typedef T2 second_type; |
|---|
| 22 | typedef typename call_traits<first_type>::param_type first_param_type; |
|---|
| 23 | typedef typename call_traits<second_type>::param_type second_param_type; |
|---|
| 24 | typedef typename call_traits<first_type>::reference first_reference; |
|---|
| 25 | typedef typename call_traits<second_type>::reference second_reference; |
|---|
| 26 | typedef typename call_traits<first_type>::const_reference first_const_reference; |
|---|
| 27 | typedef typename call_traits<second_type>::const_reference second_const_reference; |
|---|
| 28 | |
|---|
| 29 | compressed_pair() : base() {} |
|---|
| 30 | compressed_pair(first_param_type x, second_param_type y); |
|---|
| 31 | explicit compressed_pair(first_param_type x); |
|---|
| 32 | explicit compressed_pair(second_param_type y); |
|---|
| 33 | |
|---|
| 34 | compressed_pair& operator=(const compressed_pair&); |
|---|
| 35 | |
|---|
| 36 | first_reference first(); |
|---|
| 37 | first_const_reference first() const; |
|---|
| 38 | |
|---|
| 39 | second_reference second(); |
|---|
| 40 | second_const_reference second() const; |
|---|
| 41 | |
|---|
| 42 | void swap(compressed_pair& y); |
|---|
| 43 | };</pre> |
|---|
| 44 | <p>The two members of the pair can be accessed using the member functions first() |
|---|
| 45 | and second(). Note that not all member functions can be instantiated for all |
|---|
| 46 | template parameter types. In particular compressed_pair can be instantiated for |
|---|
| 47 | reference and array types, however in these cases the range of constructors |
|---|
| 48 | that can be used are limited. If types T1 and T2 are the same type, then there |
|---|
| 49 | is only one version of the single-argument constructor, and this constructor |
|---|
| 50 | initialises both values in the pair to the passed value.</p> |
|---|
| 51 | <P>Note that if either member is a POD type, then that member is not |
|---|
| 52 | zero-initialized by the compressed_pair default constructor: it's up to you to |
|---|
| 53 | supply an initial value for these types if you want them to have a default |
|---|
| 54 | value.</P> |
|---|
| 55 | <p>Note that compressed_pair can not be instantiated if either of the template |
|---|
| 56 | arguments is a union type, unless there is compiler support for |
|---|
| 57 | boost::is_union, or if boost::is_union is specialised for the union type.</p> |
|---|
| 58 | <p>Finally, a word of caution for Visual C++ 6 users: if either argument is an |
|---|
| 59 | empty type, then assigning to that member will produce memory corruption, |
|---|
| 60 | unless the empty type has a "do nothing" assignment operator defined. This is |
|---|
| 61 | due to a bug in the way VC6 generates implicit assignment operators.</p> |
|---|
| 62 | <hr> |
|---|
| 63 | <p>Revised 08 May 2001</p> |
|---|
| 64 | <p>© Copyright boost.org 2000. Permission to copy, use, modify, sell and |
|---|
| 65 | distribute this document is granted provided this copyright notice appears in |
|---|
| 66 | all copies. This document is provided "as is" without express or implied |
|---|
| 67 | warranty, and with no claim as to its suitability for any purpose.</p> |
|---|
| 68 | <p>Based on contributions by Steve Cleary, Beman Dawes, Howard Hinnant and John |
|---|
| 69 | Maddock.</p> |
|---|
| 70 | <p>Maintained by <a href="mailto:john@johnmaddock.co.uk">John Maddock</a>, the |
|---|
| 71 | latest version of this file can be found at <a href="http://www.boost.org">www.boost.org</a>, |
|---|
| 72 | and the boost discussion list at <a href="http://www.yahoogroups.com/list/boost">www.yahoogroups.com/list/boost</a>.</p> |
|---|
| 73 | <p> </p> |
|---|
| 74 | </body> |
|---|
| 75 | </html> |
|---|