| 1 | #pragma once
|
|---|
| 2 |
|
|---|
| 3 | #include <cstddef>
|
|---|
| 4 | #include <type_traits>
|
|---|
| 5 | #include <limits>
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 | // Specializing hash<> for user-defined type in std namespace, this is standard conforming.
|
|---|
| 9 | namespace std {
|
|---|
| 10 |
|
|---|
| 11 | template <typename Vertex, typename EdgeIndex>
|
|---|
| 12 | struct hash<boost::detail::csr_edge_descriptor<Vertex, EdgeIndex>> {
|
|---|
| 13 | std::size_t operator()(const boost::detail::csr_edge_descriptor<Vertex, EdgeIndex>& edge_descriptor) const noexcept {
|
|---|
| 14 |
|
|---|
| 15 | static_assert(std::is_unsigned<EdgeIndex>(),
|
|---|
| 16 | "An unsigned EdgeIndex is required for simple hashing returning the edge descriptor's index");
|
|---|
| 17 | static_assert(std::numeric_limits<EdgeIndex>::max() <= std::numeric_limits<std::size_t>::max(),
|
|---|
| 18 | "EdgeIndex too large for simple hashing returning the edge descriptor's index");
|
|---|
| 19 |
|
|---|
| 20 | return edge_descriptor.idx;
|
|---|
| 21 | }
|
|---|
| 22 | };
|
|---|
| 23 | }
|
|---|