23 #ifndef EDSP_INDEX_OF_HPP 24 #define EDSP_INDEX_OF_HPP 29 namespace edsp {
inline namespace algorithm {
38 template <
typename ForwardIt>
39 constexpr std::int32_t
indexof(ForwardIt first, ForwardIt last,
40 const typename std::iterator_traits<ForwardIt>::value_type & value) {
41 const auto element = std::find(first, last, value);
42 return static_cast<int32_t
>((element != last) ?
std::distance(first, element) : -1);
46 #endif //EDSP_INDEX_OF_HPP constexpr T distance(T x, T y) noexcept
Computes the distance between x and y.
Definition: numeric.hpp:328
constexpr std::int32_t indexof(ForwardIt first, ForwardIt last, const typename std::iterator_traits< ForwardIt >::value_type &value)
Searches for an element equivalent to value in the range [first, last) and returns its position...
Definition: indexof.hpp:39
Definition: amplifier.hpp:29