forked from ecell/epdp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DomainID.hpp
59 lines (50 loc) · 1.34 KB
/
DomainID.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#ifndef DOMAIN_ID_HPP
#define DOMAIN_ID_HPP
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */
#include <ostream>
#if defined(HAVE_TR1_FUNCTIONAL)
#include <tr1/functional>
#elif defined(HAVE_STD_HASH)
#include <functional>
#elif defined(HAVE_BOOST_FUNCTIONAL_HASH_HPP)
#include <boost/functional/hash.hpp>
#endif
#include "Identifier.hpp"
struct DomainID: public Identifier<DomainID, unsigned long long, int>
{
typedef Identifier<DomainID, unsigned long long, int> base_type;
DomainID(value_type const& value = value_type(0, 0))
: base_type(value) {}
};
#if defined(HAVE_TR1_FUNCTIONAL)
namespace std { namespace tr1 {
#elif defined(HAVE_STD_HASH)
namespace std {
#elif defined(HAVE_BOOST_FUNCTIONAL_HASH_HPP)
namespace boost {
#endif
template<>
struct hash<DomainID>
{
std::size_t operator()(DomainID const& val) const
{
return static_cast<std::size_t>(val().first ^ val().second);
}
};
#if defined(HAVE_TR1_FUNCTIONAL)
} } // namespace std::tr1
#elif defined(HAVE_STD_HASH)
} // namespace std
#elif defined(HAVE_BOOST_FUNCTIONAL_HASH_HPP)
} // namespace boost
#endif
template<typename Tstrm_>
inline std::basic_ostream<Tstrm_>& operator<<(std::basic_ostream<Tstrm_>& strm,
const DomainID& v)
{
strm << "DID(" << v().first << ":" << v().second << ")";
return strm;
}
#endif /* DOMAIN_ID_HPP */