NCBI C++ ToolKit
|
Search Toolkit Book for pair_base_member
Template used for empty base class optimization. More...
#include <corelib/ncbimisc.hpp>
Public Types | |
typedef Base | base_type |
typedef Base | first_type |
typedef Member | member_type |
typedef Member | second_type |
Public Member Functions | |
pair_base_member (void) | |
pair_base_member (const member_type &member_value) | |
pair_base_member (const first_type &first_value, const second_type &second_value) | |
const first_type & | first () const |
first_type & | first () |
const second_type & | second () const |
second_type & | second () |
void | Swap (pair_base_member< first_type, second_type > &p) |
Private Attributes | |
member_type | m_Member |
Template used for empty base class optimization.
See details in the August '97 "C++ Issue" of Dr. Dobb's Journal Also available from http://www.cantrip.org/emptyopt.html We store usually empty template argument class together with data member. This template is much like STL's pair<>, but the access to members is done though methods first() and second() returning references to corresponding members. First template argument is represented as private base class, while second template argument is represented as private member. In addition to constructor taking two arguments, we add constructor for initialization of only data member (second). This is useful since usually first type is empty and doesn't require non-trivial constructor. We do not define any comparison functions as this template is intented to be used internally within another templates, which themselves should provide any additional functionality.
Definition at line 245 of file ncbimisc.hpp.