hashed.hpp
Go to the documentation of this file.
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2018-2020 Mikhail Komarov <nemo@nil.foundation>
3 //
4 // MIT License
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in all
14 // copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 // SOFTWARE.
23 //---------------------------------------------------------------------------//
24 
25 #ifndef CRYPTO3_HASHED_HPP
26 #define CRYPTO3_HASHED_HPP
27 
28 #include <boost/range/concepts.hpp>
29 #include <boost/range/adaptor/argument_fwd.hpp>
30 
33 
34 namespace nil {
35  namespace crypto3 {
36  namespace hashes {
37  namespace detail {
38  template<typename HashAccumulator, typename SinglePassRange>
40  operator|(SinglePassRange &r, const detail::value_hash_impl<HashAccumulator> &f) {
41  BOOST_CONCEPT_ASSERT((boost::SinglePassRangeConcept<SinglePassRange>));
42 
43  typedef detail::value_hash_impl<HashAccumulator> StreamHashImpl;
45 
46  return HashImpl(r, HashAccumulator());
47  }
48 
49  template<typename HashAccumulator, typename SinglePassRange>
51  operator|(const SinglePassRange &r, const detail::value_hash_impl<HashAccumulator> &f) {
52  BOOST_CONCEPT_ASSERT((boost::SinglePassRangeConcept<const SinglePassRange>));
53 
54  typedef detail::value_hash_impl<HashAccumulator> StreamHashImpl;
56 
57  return HashImpl(r, HashAccumulator());
58  }
59 
60  template<typename HashAccumulator, typename SinglePassRange>
62  operator|(std::initializer_list<SinglePassRange> r,
64  BOOST_CONCEPT_ASSERT((boost::SinglePassRangeConcept<SinglePassRange>));
65 
66  typedef detail::value_hash_impl<HashAccumulator> StreamHashImpl;
68 
69  return HashImpl(r, HashAccumulator());
70  }
71  } // namespace detail
72  } // namespace hashes
73 
74  namespace adaptors {
75  namespace {
76  template<typename Hash, typename HashAccumulator = accumulator_set<Hash>>
77  const hashes::detail::value_hash_impl<HashAccumulator>
78  hashed = hashes::detail::value_hash_impl<HashAccumulator>(HashAccumulator());
79  }
80  } // namespace adaptors
81  } // namespace crypto3
82 } // namespace nil
83 
84 #endif // CRYPTO3_HASHED_HPP
detail::range_hash_impl< detail::value_hash_impl< HashAccumulator > > operator|(SinglePassRange &r, const detail::value_hash_impl< HashAccumulator > &f)
Definition: hashed.hpp:40
Definition: pair.hpp:31