CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/JetMETCorrections/FFTJetObjects/interface/FFTJetDict.h

Go to the documentation of this file.
00001 #ifndef JetMETCorrections_FFTJetObjects_FFTJetDict_h
00002 #define JetMETCorrections_FFTJetObjects_FFTJetDict_h
00003 
00004 //
00005 // This template provides a variation of std::map with
00006 // subscripting operator which does not automatically
00007 // insert default values
00008 //
00009 // I. Volobouev
00010 // 08/03/2012
00011 
00012 #include <map>
00013 #include "FWCore/Utilities/interface/Exception.h"
00014 
00015 template <class Key, class T,
00016           class Compare = std::less<Key>,
00017           class Allocator = std::allocator<std::pair<const Key,T> > >
00018 struct FFTJetDict : public std::map<Key,T,Compare,Allocator>
00019 {
00020     inline T& operator[](const Key&) const;
00021 };
00022 
00023 template<class Key,class T,class Compare,class Allocator>
00024 T& FFTJetDict<Key,T,Compare,Allocator>::
00025 operator[](const Key& key) const
00026 {
00027     typename FFTJetDict<Key,T,Compare,Allocator>::const_iterator it = 
00028         this->find(key);
00029     if (it == std::map<Key,T,Compare,Allocator>::end())
00030         throw cms::Exception("KeyNotFound")
00031             << "FFTJetDict: key \"" << key << "\" not found\n";
00032     return const_cast<T&>(it->second);
00033 }
00034 
00035 #endif // JetMETCorrections_FFTJetObjects_FFTJetDict_h