Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:18

0001 #ifndef CommonTools_Utils_PointerComparator_h
0002 #define CommonTools_Utils_PointerComparator_h
0003 /** \class PoinetComparator
0004  *
0005  * adapt a comparator to take pointers as arguments
0006  * 
0007  * \author Luca Lista, INFN
0008  *
0009  * \version $Revision: 1.1 $
0010  *
0011  * $Id: PointerComparator.h,v 1.1 2007/04/23 20:43:09 llista Exp $
0012  *
0013  */
0014 #include "FWCore/Utilities/interface/EDMException.h"
0015 
0016 template <typename C>
0017 struct PointerComparator {
0018   typedef typename C::first_argument_type first_argument_type;
0019   typedef typename C::second_argument_type second_argument_type;
0020   bool operator()(const first_argument_type* t1, const second_argument_type* t2) const {
0021     if (t1 == nullptr || t2 == nullptr)
0022       throw edm::Exception(edm::errors::NullPointerError) << "PointerComparator: passed null pointer.";
0023     return cmp(*t1, *t2);
0024   }
0025   C cmp;
0026 };
0027 
0028 #endif