26 #ifndef CRYPTO3_STRXOR_HPP
27 #define CRYPTO3_STRXOR_HPP
29 #include <boost/concept/assert.hpp>
30 #include <boost/assert.hpp>
37 template<
typename InputIterator1,
typename InputIterator2,
typename OutputIterator>
39 typename std::enable_if<std::is_same<typename std::iterator_traits<InputIterator1>::value_type,
40 typename std::iterator_traits<InputIterator2>::value_type>::value,
42 strxor(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2,
44 BOOST_ASSERT(std::distance(first1, last1) == std::distance(first2, last2));
46 while (first1 != last1 && first2 != last2) {
47 *out++ = *first1++ ^ *first2++;
51 template<
typename InputType,
typename OutputType>
52 constexpr
inline void strxor(
const InputType &in1,
const InputType &in2, OutputType &out) {
53 BOOST_CONCEPT_ASSERT((boost::SinglePassRangeConcept<InputType>));
54 BOOST_CONCEPT_ASSERT((boost::SinglePassRangeConcept<OutputType>));
55 BOOST_CONCEPT_ASSERT((boost::WriteableRangeConcept<OutputType>));
57 BOOST_ASSERT(std::distance(in1.begin(), in1.end()) == std::distance(in2.begin(), in2.end()) &&
58 std::distance(in1.begin(), in1.end()) == std::distance(out.begin(), out.end()));
60 auto in1_i = in1.begin();
61 auto in2_i = in2.begin();
62 auto out_i = out.begin();
63 while (in1_i != in1.end() && in2_i != in2.end()) {
64 *out_i++ = *in1_i++ ^ *in2_i++;
constexpr std::enable_if< std::is_same< typename std::iterator_traits< InputIterator1 >::value_type, typename std::iterator_traits< InputIterator2 >::value_type >::value, OutputIterator >::type strxor(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator out)
Definition: algebra/include/nil/crypto3/algebra/algorithms/strxor.hpp:42