Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

qpair.h

Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Definition of QPair class
00004 **
00005 **
00006 ** Copyright (C) 1992-2001 Trolltech AS.  All rights reserved.
00007 **
00008 ** This file is part of the tools module of the Qt GUI Toolkit.
00009 **
00010 ** This file may be distributed under the terms of the Q Public License
00011 ** as defined by Trolltech AS of Norway and appearing in the file
00012 ** LICENSE.QPL included in the packaging of this file.
00013 **
00014 ** This file may be distributed and/or modified under the terms of the
00015 ** GNU General Public License version 2 as published by the Free Software
00016 ** Foundation and appearing in the file LICENSE.GPL included in the
00017 ** packaging of this file.
00018 **
00019 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00020 ** licenses may use this file in accordance with the Qt Commercial License
00021 ** Agreement provided with the Software.
00022 **
00023 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00024 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00025 **
00026 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00027 **   information about Qt Commercial License Agreements.
00028 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00029 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00030 **
00031 ** Contact info@trolltech.com if any conditions of this licensing are
00032 ** not clear to you.
00033 **
00034 **********************************************************************/
00035 
00036 #ifndef QPAIR_H
00037 #define QPAIR_H
00038 
00039 #ifndef QT_H
00040 #include "qglobal.h"
00041 #include "qdatastream.h"
00042 #endif // QT_H
00043 
00044 template <class T1, class T2>
00045 struct QPair
00046 {
00047     typedef T1 first_type;
00048     typedef T2 second_type;
00049 
00050     QPair()
00051         : first( T1() ), second( T2() )
00052     {}
00053     QPair( const T1& t1, const T2& t2 )
00054         : first( t1 ), second( t2 )
00055     {}
00056 
00057     T1 first;
00058     T2 second;
00059 };
00060 
00061 template <class T1, class T2>
00062 Q_INLINE_TEMPLATES bool operator==( const QPair<T1, T2>& x, const QPair<T1, T2>& y )
00063 {
00064     return x.first == y.first && x.second == y.second;
00065 }
00066 
00067 template <class T1, class T2>
00068 Q_INLINE_TEMPLATES bool operator<( const QPair<T1, T2>& x, const QPair<T1, T2>& y )
00069 {
00070     return x.first < y.first ||
00071            ( !( y.first < x.first ) && x.second < y.second );
00072 }
00073 
00074 template <class T1, class T2>
00075 Q_INLINE_TEMPLATES QPair<T1, T2> qMakePair( const T1& x, const T2& y )
00076 {
00077     return QPair<T1, T2>( x, y );
00078 }
00079 
00080 #ifndef QT_NO_DATASTREAM
00081 template <class T1, class T2>
00082 inline QDataStream& operator>>( QDataStream& s, QPair<T1, T2>& p )
00083 {
00084     s >> p.first >> p.second;
00085     return s;
00086 }
00087 
00088 template <class T1, class T2>
00089 inline QDataStream& operator<<( QDataStream& s, const QPair<T1, T2>& p )
00090 {
00091     s << p.first << p.second;
00092     return s;
00093 }
00094 #endif
00095 
00096 #endif

Generated on Sat Nov 5 16:18:26 2005 for OPIE by  doxygen 1.4.2