Silicium
range_value.hpp
Go to the documentation of this file.
1 #ifndef SILICIUM_RANGE_VALUE_HPP
2 #define SILICIUM_RANGE_VALUE_HPP
3 
4 #include <silicium/config.hpp>
5 #include <boost/range/algorithm/equal.hpp>
6 #include <boost/range/begin.hpp>
7 #include <boost/range/end.hpp>
8 #include <boost/functional/hash.hpp>
9 
10 namespace Si
11 {
12  template <class BidirectionalRange>
13  struct range_value
14  {
15  BidirectionalRange range;
16 
18  {
19  }
20 
21  range_value(BidirectionalRange range)
22  : range(std::move(range))
23  {
24  }
25  };
26 
27  template <class BidirectionalRange1, class BidirectionalRange2>
29  {
30  return boost::range::equal(left.range, right.range);
31  }
32 
33  template <class BidirectionalRange>
34  auto make_range_value(BidirectionalRange &&range)
35 #if !SILICIUM_COMPILER_HAS_AUTO_RETURN_TYPE
37 #endif
38  {
39  return range_value<typename std::decay<BidirectionalRange>::type>(std::forward<BidirectionalRange>(range));
40  }
41 }
42 
43 namespace std
44 {
45  template <class BidirectionalRange>
46  struct hash<Si::range_value<BidirectionalRange>>
47  {
48  std::size_t operator()(Si::range_value<BidirectionalRange> const &value) const
49  {
50  using boost::begin;
51  using boost::end;
52  return boost::hash_range(begin(value.range), end(value.range));
53  }
54  };
55 }
56 
57 #endif
auto make_range_value(BidirectionalRange &&range) -> range_value< typename std::decay< BidirectionalRange >::type >
Definition: range_value.hpp:34
std::remove_reference< T >::type && move(T &&ref)
Definition: move.hpp:10
BidirectionalRange range
Definition: range_value.hpp:15
Definition: absolute_path.hpp:352
Definition: absolute_path.hpp:19
BOOST_CONSTEXPR Iterator const & end(iterator_range< Iterator > const &range)
Definition: iterator_range.hpp:136
std::size_t operator()(Si::range_value< BidirectionalRange > const &value) const
Definition: range_value.hpp:48
range_value(BidirectionalRange range)
Definition: range_value.hpp:21
BOOST_CONSTEXPR Iterator const & begin(iterator_range< Iterator > const &range)
Definition: iterator_range.hpp:123
SILICIUM_USE_RESULT bool operator==(absolute_path const &left, ComparableToPath const &right)
Definition: absolute_path.hpp:169
Definition: range_value.hpp:13
range_value()
Definition: range_value.hpp:17