#ifndef TRANSLATOR_H
#define TRANSLATOR_H
-
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
+#include "support/LAssert.h"
+
// Functors used in the template.
template<typename T1, typename T2>
class equal_1st_in_pair {
public:
typedef T1 first_argument_type;
typedef T2 second_argument_type;
+ typedef std::pair<T1, T2> MapPair;
+ typedef std::vector<MapPair> Map;
/// c-tor.
Translator(T1 const & t1, T2 const & t2)
/// Find the mapping for the first argument
T2 const & find(T1 const & first) const {
-#ifdef ENABLE_ASSERTIONS
Assert( ! map.empty());
-#endif
// For explanation see the next find() function.
Map::const_iterator it =
/// Find the mapping for the second argument
T1 const & find(T2 const & second) const {
-#ifdef ENABLE_ASSERTIONS
Assert( ! map.empty());
-#endif
// The idea is as follows:
// find_if() will try to compare the data in the vector with the value.
}
private:
- typedef std::pair<T1, T2> MapPair;
- typedef std::vector<MapPair> Map;
-
Map map;
- const T1 default_t1;
- const T2 default_t2;
-
+ T1 const default_t1;
+ T2 const default_t2;
};
#endif