Use __func__ only if the compiler supports it (ticket #148).
1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
19 #ifndef LEMON_BITS_TRAITS_H
20 #define LEMON_BITS_TRAITS_H
23 ///\brief Traits for graphs and maps
26 #include <lemon/bits/enable_if.h>
30 struct InvalidType {};
32 template <typename _Graph, typename _Item>
33 class ItemSetTraits {};
36 template <typename Graph, typename Enable = void>
37 struct NodeNotifierIndicator {
38 typedef InvalidType Type;
40 template <typename Graph>
41 struct NodeNotifierIndicator<
43 typename enable_if<typename Graph::NodeNotifier::Notifier, void>::type
45 typedef typename Graph::NodeNotifier Type;
48 template <typename _Graph>
49 class ItemSetTraits<_Graph, typename _Graph::Node> {
54 typedef typename Graph::Node Item;
55 typedef typename Graph::NodeIt ItemIt;
57 typedef typename NodeNotifierIndicator<Graph>::Type ItemNotifier;
59 template <typename _Value>
60 class Map : public Graph::template NodeMap<_Value> {
62 typedef typename Graph::template NodeMap<_Value> Parent;
63 typedef typename Graph::template NodeMap<_Value> Type;
64 typedef typename Parent::Value Value;
66 Map(const Graph& _digraph) : Parent(_digraph) {}
67 Map(const Graph& _digraph, const Value& _value)
68 : Parent(_digraph, _value) {}
74 template <typename Graph, typename Enable = void>
75 struct ArcNotifierIndicator {
76 typedef InvalidType Type;
78 template <typename Graph>
79 struct ArcNotifierIndicator<
81 typename enable_if<typename Graph::ArcNotifier::Notifier, void>::type
83 typedef typename Graph::ArcNotifier Type;
86 template <typename _Graph>
87 class ItemSetTraits<_Graph, typename _Graph::Arc> {
92 typedef typename Graph::Arc Item;
93 typedef typename Graph::ArcIt ItemIt;
95 typedef typename ArcNotifierIndicator<Graph>::Type ItemNotifier;
97 template <typename _Value>
98 class Map : public Graph::template ArcMap<_Value> {
100 typedef typename Graph::template ArcMap<_Value> Parent;
101 typedef typename Graph::template ArcMap<_Value> Type;
102 typedef typename Parent::Value Value;
104 Map(const Graph& _digraph) : Parent(_digraph) {}
105 Map(const Graph& _digraph, const Value& _value)
106 : Parent(_digraph, _value) {}
111 template <typename Graph, typename Enable = void>
112 struct EdgeNotifierIndicator {
113 typedef InvalidType Type;
115 template <typename Graph>
116 struct EdgeNotifierIndicator<
118 typename enable_if<typename Graph::EdgeNotifier::Notifier, void>::type
120 typedef typename Graph::EdgeNotifier Type;
123 template <typename _Graph>
124 class ItemSetTraits<_Graph, typename _Graph::Edge> {
127 typedef _Graph Graph;
129 typedef typename Graph::Edge Item;
130 typedef typename Graph::EdgeIt ItemIt;
132 typedef typename EdgeNotifierIndicator<Graph>::Type ItemNotifier;
134 template <typename _Value>
135 class Map : public Graph::template EdgeMap<_Value> {
137 typedef typename Graph::template EdgeMap<_Value> Parent;
138 typedef typename Graph::template EdgeMap<_Value> Type;
139 typedef typename Parent::Value Value;
141 Map(const Graph& _digraph) : Parent(_digraph) {}
142 Map(const Graph& _digraph, const Value& _value)
143 : Parent(_digraph, _value) {}
148 template <typename Map, typename Enable = void>
150 typedef False ReferenceMapTag;
152 typedef typename Map::Key Key;
153 typedef typename Map::Value Value;
155 typedef Value ConstReturnValue;
156 typedef Value ReturnValue;
159 template <typename Map>
161 Map, typename enable_if<typename Map::ReferenceMapTag, void>::type >
163 typedef True ReferenceMapTag;
165 typedef typename Map::Key Key;
166 typedef typename Map::Value Value;
168 typedef typename Map::ConstReference ConstReturnValue;
169 typedef typename Map::Reference ReturnValue;
171 typedef typename Map::ConstReference ConstReference;
172 typedef typename Map::Reference Reference;
175 template <typename MatrixMap, typename Enable = void>
176 struct MatrixMapTraits {
177 typedef False ReferenceMapTag;
179 typedef typename MatrixMap::FirstKey FirstKey;
180 typedef typename MatrixMap::SecondKey SecondKey;
181 typedef typename MatrixMap::Value Value;
183 typedef Value ConstReturnValue;
184 typedef Value ReturnValue;
187 template <typename MatrixMap>
188 struct MatrixMapTraits<
189 MatrixMap, typename enable_if<typename MatrixMap::ReferenceMapTag,
192 typedef True ReferenceMapTag;
194 typedef typename MatrixMap::FirstKey FirstKey;
195 typedef typename MatrixMap::SecondKey SecondKey;
196 typedef typename MatrixMap::Value Value;
198 typedef typename MatrixMap::ConstReference ConstReturnValue;
199 typedef typename MatrixMap::Reference ReturnValue;
201 typedef typename MatrixMap::ConstReference ConstReference;
202 typedef typename MatrixMap::Reference Reference;
205 // Indicators for the tags
207 template <typename Graph, typename Enable = void>
208 struct NodeNumTagIndicator {
209 static const bool value = false;
212 template <typename Graph>
213 struct NodeNumTagIndicator<
215 typename enable_if<typename Graph::NodeNumTag, void>::type
217 static const bool value = true;
220 template <typename Graph, typename Enable = void>
221 struct EdgeNumTagIndicator {
222 static const bool value = false;
225 template <typename Graph>
226 struct EdgeNumTagIndicator<
228 typename enable_if<typename Graph::EdgeNumTag, void>::type
230 static const bool value = true;
233 template <typename Graph, typename Enable = void>
234 struct FindEdgeTagIndicator {
235 static const bool value = false;
238 template <typename Graph>
239 struct FindEdgeTagIndicator<
241 typename enable_if<typename Graph::FindEdgeTag, void>::type
243 static const bool value = true;
246 template <typename Graph, typename Enable = void>
247 struct UndirectedTagIndicator {
248 static const bool value = false;
251 template <typename Graph>
252 struct UndirectedTagIndicator<
254 typename enable_if<typename Graph::UndirectedTag, void>::type
256 static const bool value = true;
259 template <typename Graph, typename Enable = void>
260 struct BuildTagIndicator {
261 static const bool value = false;
264 template <typename Graph>
265 struct BuildTagIndicator<
267 typename enable_if<typename Graph::BuildTag, void>::type
269 static const bool value = true;