Sierra Toolkit Version of the Day
NamedPair.hpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010 Sandia Corporation.                     */
00003 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00004 /*  license for use of this work by or on behalf of the U.S. Government.  */
00005 /*  Export of this program may require a license from the                 */
00006 /*  United States Government.                                             */
00007 /*------------------------------------------------------------------------*/
00008 
00009 #ifndef stk_util_util_NamedPair_hpp
00010 #define stk_util_util_NamedPair_hpp
00011 
00012 #define NAMED_PAIR( STRUCT_NAME , FIRST_TYPE , FIRST_NAME , SECOND_TYPE , SECOND_NAME ) \
00013 struct STRUCT_NAME {  \
00014   typedef FIRST_TYPE first_type; \
00015   typedef SECOND_TYPE second_type; \
00016   \
00017   first_type  FIRST_NAME ; \
00018   second_type SECOND_NAME ; \
00019   \
00020   STRUCT_NAME ( const first_type & arg_ ## FIRST_NAME , \
00021                 const second_type & arg_ ## SECOND_NAME ) \
00022    : FIRST_NAME ( arg_ ## FIRST_NAME ) , \
00023      SECOND_NAME ( arg_ ## SECOND_NAME ) {} \
00024   \
00025   ~ STRUCT_NAME () {} \
00026   STRUCT_NAME () {} \
00027   STRUCT_NAME ( const STRUCT_NAME & arg_rhs ) \
00028    : FIRST_NAME ( arg_rhs. FIRST_NAME ) , \
00029      SECOND_NAME ( arg_rhs. SECOND_NAME ) {} \
00030   STRUCT_NAME & operator = ( const STRUCT_NAME & arg_rhs ) \
00031    { FIRST_NAME  = arg_rhs. FIRST_NAME ; \
00032      SECOND_NAME = arg_rhs. SECOND_NAME ; \
00033      return *this ; } \
00034 }; \
00035 \
00036 inline \
00037 bool operator == ( const STRUCT_NAME & arg_lhs , \
00038                    const STRUCT_NAME & arg_rhs ) \
00039   { return arg_lhs. FIRST_NAME  == arg_rhs. FIRST_NAME && \
00040            arg_lhs. SECOND_NAME == arg_rhs. SECOND_NAME ; } \
00041 \
00042 inline \
00043 bool operator != ( const STRUCT_NAME & arg_lhs , \
00044                    const STRUCT_NAME & arg_rhs ) \
00045   { return arg_lhs. FIRST_NAME  != arg_rhs. FIRST_NAME || \
00046            arg_lhs. SECOND_NAME != arg_rhs. SECOND_NAME ; } \
00047 \
00048 inline \
00049 bool operator < ( const STRUCT_NAME & arg_lhs , \
00050                   const STRUCT_NAME & arg_rhs ) \
00051   { return arg_lhs. FIRST_NAME < arg_rhs. FIRST_NAME || \
00052            ( ! ( arg_rhs. FIRST_NAME < arg_lhs. FIRST_NAME ) && \
00053            arg_lhs. SECOND_NAME < arg_rhs. SECOND_NAME ) ; } \
00054 \
00055 inline \
00056 bool operator > ( const STRUCT_NAME & arg_lhs , \
00057                   const STRUCT_NAME & arg_rhs ) \
00058   { return operator < ( arg_rhs , arg_lhs ); } \
00059 
00060 #endif
00061 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends