ATLAS Offline Software
KeyConcept.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef CONSTRAINTS_KEYCONCEPT_H
6 #define CONSTRAINTS_KEYCONCEPT_H
7 #include <string>
8 #include <boost/concept_check.hpp>
9 
10 //CONCEPT
11 template <class T, class ID=std::string >
12 struct KeyConcept {
13  void constraints() {
14  // check that key can be converted to an identifier
15  //needed? boost::function_requires< boost::ConvertibleConcept<ID, T> >();
16  boost::function_requires< boost::ConvertibleConcept<T, ID> >();
17  //should also have boost::function_requires< boost::LessThanComparableConcept<T> >();
18  }
19  T a;
20 };
21 
22 template<std::size_t N>
23 struct KeyConcept<char[N], std::string> {
24  void constraints() { } //no check for char arrays
25 };
26 
27 template<>
28 struct KeyConcept<char*, std::string> {
29  void constraints() { } //no check for char arrays
30 };
31 
32 template<>
33 struct KeyConcept<char, std::string> {
34  void constraints() { } //no check for char arrays
35 };
36 template<>
37 struct KeyConcept<short, std::string> {
38  void constraints() { } //no check for char arrays
39 };
40 template<>
41 struct KeyConcept<int, std::string> {
42  void constraints() { } //no check for char arrays
43 };
44 template<>
45 struct KeyConcept<long, std::string> {
46  void constraints() { } //no check for char arrays
47 };
48 template<>
49 struct KeyConcept<long long, std::string> {
50  void constraints() { } //no check for char arrays
51 };
52 template<>
53 struct KeyConcept<unsigned char, std::string> {
54  void constraints() { } //no check for char arrays
55 };
56 template<>
57 struct KeyConcept<unsigned short, std::string> {
58  void constraints() { } //no check for char arrays
59 };
60 template<>
61 struct KeyConcept<unsigned int, std::string> {
62  void constraints() { } //no check for char arrays
63 };
64 template<>
65 struct KeyConcept<unsigned long, std::string> {
66  void constraints() { } //no check for char arrays
67 };
68 template<>
69 struct KeyConcept<unsigned long long, std::string> {
70  void constraints() { } //no check for char arrays
71 };
72 
73 
74 //HELPER FUNCTION AND CLASS TO EXPRESS THE CHECK IN A COMPACT FASHION
75 template <class T>
76 inline int classIsKey() {
77 #ifndef SKIP_GCC_INTERNAL_ERROR_980519
78  //triggers an internal error in 2.91
79  boost::function_requires< KeyConcept<T> > ();
80 #endif
81  return 0;
82 }
83 
84 template <class T>
85 struct KeyClass {
86  KeyClass() {}
87  ~KeyClass() {}
89 };
90 
91 #endif
92 
93 
94 
95 
96 
97 
98 
KeyConcept< unsigned long long, std::string >::constraints
void constraints()
Definition: KeyConcept.h:70
xAOD::short
short
Definition: Vertex_v1.cxx:165
KeyConcept< char, std::string >::constraints
void constraints()
Definition: KeyConcept.h:34
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
KeyConcept< short, std::string >::constraints
void constraints()
Definition: KeyConcept.h:38
xAOD::char
char
Definition: TrigDecision_v1.cxx:38
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
KeyConcept< char *, std::string >::constraints
void constraints()
Definition: KeyConcept.h:29
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
KeyConcept< int, std::string >::constraints
void constraints()
Definition: KeyConcept.h:42
KeyConcept< unsigned long, std::string >::constraints
void constraints()
Definition: KeyConcept.h:66
KeyConcept< char[N], std::string >::constraints
void constraints()
Definition: KeyConcept.h:24
classIsKey
int classIsKey()
Definition: KeyConcept.h:76
KeyClass::KeyClass
KeyClass()
Definition: KeyConcept.h:86
KeyConcept::a
T a
Definition: KeyConcept.h:19
KeyConcept< unsigned short, std::string >::constraints
void constraints()
Definition: KeyConcept.h:58
KeyClass
Definition: KeyConcept.h:85
KeyConcept::constraints
void constraints()
Definition: KeyConcept.h:13
KeyConcept< long, std::string >::constraints
void constraints()
Definition: KeyConcept.h:46
KeyConcept< unsigned char, std::string >::constraints
void constraints()
Definition: KeyConcept.h:54
KeyConcept< unsigned int, std::string >::constraints
void constraints()
Definition: KeyConcept.h:62
KeyConcept
Definition: KeyConcept.h:12
KeyClass::BOOST_CONCEPT_ASSERT
BOOST_CONCEPT_ASSERT((KeyConcept< T >))
KeyClass::~KeyClass
~KeyClass()
Definition: KeyConcept.h:87
TSU::T
unsigned long long T
Definition: L1TopoDataTypes.h:35
KeyConcept< long long, std::string >::constraints
void constraints()
Definition: KeyConcept.h:50