Add missing include header and std:: namespace spec. (#487)
1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2013
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 GR, typename _Item>
33 class ItemSetTraits {};
36 template <typename GR, typename Enable = void>
37 struct NodeNotifierIndicator {
38 typedef InvalidType Type;
40 template <typename GR>
41 struct NodeNotifierIndicator<
43 typename enable_if<typename GR::NodeNotifier::Notifier, void>::type
45 typedef typename GR::NodeNotifier Type;
48 template <typename GR>
49 class ItemSetTraits<GR, typename GR::Node> {
55 typedef typename GR::Node Item;
56 typedef typename GR::NodeIt ItemIt;
58 typedef typename NodeNotifierIndicator<GR>::Type ItemNotifier;
61 class Map : public GR::template NodeMap<V> {
62 typedef typename GR::template NodeMap<V> Parent;
65 typedef typename GR::template NodeMap<V> Type;
66 typedef typename Parent::Value Value;
68 Map(const GR& _digraph) : Parent(_digraph) {}
69 Map(const GR& _digraph, const Value& _value)
70 : Parent(_digraph, _value) {}
76 template <typename GR, typename Enable = void>
77 struct ArcNotifierIndicator {
78 typedef InvalidType Type;
80 template <typename GR>
81 struct ArcNotifierIndicator<
83 typename enable_if<typename GR::ArcNotifier::Notifier, void>::type
85 typedef typename GR::ArcNotifier Type;
88 template <typename GR>
89 class ItemSetTraits<GR, typename GR::Arc> {
95 typedef typename GR::Arc Item;
96 typedef typename GR::ArcIt ItemIt;
98 typedef typename ArcNotifierIndicator<GR>::Type ItemNotifier;
100 template <typename V>
101 class Map : public GR::template ArcMap<V> {
102 typedef typename GR::template ArcMap<V> Parent;
105 typedef typename GR::template ArcMap<V> Type;
106 typedef typename Parent::Value Value;
108 Map(const GR& _digraph) : Parent(_digraph) {}
109 Map(const GR& _digraph, const Value& _value)
110 : Parent(_digraph, _value) {}
115 template <typename GR, typename Enable = void>
116 struct EdgeNotifierIndicator {
117 typedef InvalidType Type;
119 template <typename GR>
120 struct EdgeNotifierIndicator<
122 typename enable_if<typename GR::EdgeNotifier::Notifier, void>::type
124 typedef typename GR::EdgeNotifier Type;
127 template <typename GR>
128 class ItemSetTraits<GR, typename GR::Edge> {
134 typedef typename GR::Edge Item;
135 typedef typename GR::EdgeIt ItemIt;
137 typedef typename EdgeNotifierIndicator<GR>::Type ItemNotifier;
139 template <typename V>
140 class Map : public GR::template EdgeMap<V> {
141 typedef typename GR::template EdgeMap<V> Parent;
144 typedef typename GR::template EdgeMap<V> Type;
145 typedef typename Parent::Value Value;
147 Map(const GR& _digraph) : Parent(_digraph) {}
148 Map(const GR& _digraph, const Value& _value)
149 : Parent(_digraph, _value) {}
154 template <typename GR, typename Enable = void>
155 struct RedNodeNotifierIndicator {
156 typedef InvalidType Type;
158 template <typename GR>
159 struct RedNodeNotifierIndicator<
161 typename enable_if<typename GR::RedNodeNotifier::Notifier, void>::type
163 typedef typename GR::RedNodeNotifier Type;
166 template <typename GR>
167 class ItemSetTraits<GR, typename GR::RedNode> {
174 typedef typename GR::RedNode Item;
175 typedef typename GR::RedNodeIt ItemIt;
177 typedef typename RedNodeNotifierIndicator<GR>::Type ItemNotifier;
179 template <typename V>
180 class Map : public GR::template RedNodeMap<V> {
181 typedef typename GR::template RedNodeMap<V> Parent;
184 typedef typename GR::template RedNodeMap<V> Type;
185 typedef typename Parent::Value Value;
187 Map(const GR& _bpgraph) : Parent(_bpgraph) {}
188 Map(const GR& _bpgraph, const Value& _value)
189 : Parent(_bpgraph, _value) {}
195 template <typename GR, typename Enable = void>
196 struct BlueNodeNotifierIndicator {
197 typedef InvalidType Type;
199 template <typename GR>
200 struct BlueNodeNotifierIndicator<
202 typename enable_if<typename GR::BlueNodeNotifier::Notifier, void>::type
204 typedef typename GR::BlueNodeNotifier Type;
207 template <typename GR>
208 class ItemSetTraits<GR, typename GR::BlueNode> {
215 typedef typename GR::BlueNode Item;
216 typedef typename GR::BlueNodeIt ItemIt;
218 typedef typename BlueNodeNotifierIndicator<GR>::Type ItemNotifier;
220 template <typename V>
221 class Map : public GR::template BlueNodeMap<V> {
222 typedef typename GR::template BlueNodeMap<V> Parent;
225 typedef typename GR::template BlueNodeMap<V> Type;
226 typedef typename Parent::Value Value;
228 Map(const GR& _bpgraph) : Parent(_bpgraph) {}
229 Map(const GR& _bpgraph, const Value& _value)
230 : Parent(_bpgraph, _value) {}
236 template <typename Map, typename Enable = void>
238 typedef False ReferenceMapTag;
240 typedef typename Map::Key Key;
241 typedef typename Map::Value Value;
243 typedef Value ConstReturnValue;
244 typedef Value ReturnValue;
247 template <typename Map>
249 Map, typename enable_if<typename Map::ReferenceMapTag, void>::type >
251 typedef True ReferenceMapTag;
253 typedef typename Map::Key Key;
254 typedef typename Map::Value Value;
256 typedef typename Map::ConstReference ConstReturnValue;
257 typedef typename Map::Reference ReturnValue;
259 typedef typename Map::ConstReference ConstReference;
260 typedef typename Map::Reference Reference;
263 template <typename MatrixMap, typename Enable = void>
264 struct MatrixMapTraits {
265 typedef False ReferenceMapTag;
267 typedef typename MatrixMap::FirstKey FirstKey;
268 typedef typename MatrixMap::SecondKey SecondKey;
269 typedef typename MatrixMap::Value Value;
271 typedef Value ConstReturnValue;
272 typedef Value ReturnValue;
275 template <typename MatrixMap>
276 struct MatrixMapTraits<
277 MatrixMap, typename enable_if<typename MatrixMap::ReferenceMapTag,
280 typedef True ReferenceMapTag;
282 typedef typename MatrixMap::FirstKey FirstKey;
283 typedef typename MatrixMap::SecondKey SecondKey;
284 typedef typename MatrixMap::Value Value;
286 typedef typename MatrixMap::ConstReference ConstReturnValue;
287 typedef typename MatrixMap::Reference ReturnValue;
289 typedef typename MatrixMap::ConstReference ConstReference;
290 typedef typename MatrixMap::Reference Reference;
293 // Indicators for the tags
295 template <typename GR, typename Enable = void>
296 struct NodeNumTagIndicator {
297 static const bool value = false;
300 template <typename GR>
301 struct NodeNumTagIndicator<
303 typename enable_if<typename GR::NodeNumTag, void>::type
305 static const bool value = true;
308 template <typename GR, typename Enable = void>
309 struct ArcNumTagIndicator {
310 static const bool value = false;
313 template <typename GR>
314 struct ArcNumTagIndicator<
316 typename enable_if<typename GR::ArcNumTag, void>::type
318 static const bool value = true;
321 template <typename GR, typename Enable = void>
322 struct EdgeNumTagIndicator {
323 static const bool value = false;
326 template <typename GR>
327 struct EdgeNumTagIndicator<
329 typename enable_if<typename GR::EdgeNumTag, void>::type
331 static const bool value = true;
334 template <typename GR, typename Enable = void>
335 struct FindArcTagIndicator {
336 static const bool value = false;
339 template <typename GR>
340 struct FindArcTagIndicator<
342 typename enable_if<typename GR::FindArcTag, void>::type
344 static const bool value = true;
347 template <typename GR, typename Enable = void>
348 struct FindEdgeTagIndicator {
349 static const bool value = false;
352 template <typename GR>
353 struct FindEdgeTagIndicator<
355 typename enable_if<typename GR::FindEdgeTag, void>::type
357 static const bool value = true;
360 template <typename GR, typename Enable = void>
361 struct UndirectedTagIndicator {
362 static const bool value = false;
365 template <typename GR>
366 struct UndirectedTagIndicator<
368 typename enable_if<typename GR::UndirectedTag, void>::type
370 static const bool value = true;
373 template <typename GR, typename Enable = void>
374 struct BuildTagIndicator {
375 static const bool value = false;
378 template <typename GR>
379 struct BuildTagIndicator<
381 typename enable_if<typename GR::BuildTag, void>::type
383 static const bool value = true;