You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.0 KiB
26 lines
1.0 KiB
#include <algorithm>
|
|
|
|
namespace algorithm
|
|
{
|
|
template <typename InputIt, typename OutputIt>
|
|
OutputIt find_mismatch_permutation(InputIt first, InputIt last, size_t range, OutputIt dest)
|
|
{
|
|
using input_value_type = typename std::iterator_traits<InputIt>::value_type;
|
|
using output_value_type = typename std::iterator_traits<OutputIt>::value_type;
|
|
static_assert(std::is_integral_v<input_value_type>, "InputIt must point to an integral type");
|
|
static_assert(std::is_integral_v<output_value_type>, "OutputIt must point to an integral type");
|
|
static_assert(std::is_convertible_v<input_value_type, output_value_type>,
|
|
"InputIt value type must be convertible to OutputIt value type");
|
|
using value_type = typename std::iterator_traits<InputIt>::value_type;
|
|
auto dst = dest;
|
|
for (value_type i = 0; i < range; ++i) {
|
|
auto iter = std::find(first, last, i);
|
|
if (iter == last) {
|
|
*dst = i;
|
|
dst++;
|
|
}
|
|
}
|
|
|
|
return dst;
|
|
}
|
|
} // namespace algorithm
|