19 ML_UTILS_START_NAMESPACE
30 constexpr
bool in(
U a) {
34 template <
class Arg,
class... Args>
35 constexpr
bool in(Arg a, Args... args) {
36 return in(a) || in(args...);
64 template <
class T,
class R,
typename I, I (T::*Count)() const, R *(T::*Access)(I) const>
108 return (_proxy->_object->*Access)(_index);
144 return x._proxy == y._proxy && x._index == y._index;
167 return iterator(*
this, (_object->*Count)());
190 template <
typename Range1,
typename Range2,
typename BinaryPredicate>
191 constexpr
typename Range2::const_iterator
is_rotated(
const Range1 &range1,
const Range2 &range2,
194 if (std::size(range1) != std::size(range2))
196 return std::end(range2);
198 if (std::size(range1) == 0)
200 return std::end(range2);
202 const auto itFind2 = std::find_if(std::begin(range2), std::end(range2),
203 [p, &range1](
const auto &v) {
return p(*begin(range1), v); });
205 if (itFind2 == std::end(range2))
207 return std::end(range2);
210 std::mismatch(itFind2, std::end(range2), std::begin(range1), std::end(range1), p);
211 if (resultIts.first != std::end(range2))
213 return std::end(range2);
215 resultIts = std::mismatch(std::begin(range2), itFind2, resultIts.second, std::end(range1), p);
216 if (resultIts.first != itFind2)
218 return std::end(range2);
230 template <
typename Range1,
typename Range2>
231 constexpr
typename Range2::const_iterator
is_rotated(
const Range1 &range1,
const Range2 &range2)
233 if (std::size(range1) != std::size(range2))
235 return std::end(range2);
237 if (std::size(range1) == 0)
239 return std::end(range2);
241 const auto itFind2 = std::find(std::begin(range2), std::end(range2), *begin(range1));
243 if (itFind2 == std::end(range2))
245 return std::end(range2);
247 auto resultIts = std::mismatch(itFind2, std::end(range2), std::begin(range1), std::end(range1));
248 if (resultIts.first != std::end(range2))
250 return std::end(range2);
252 resultIts = std::mismatch(std::begin(range2), itFind2, resultIts.second, std::end(range1));
253 if (resultIts.first != itFind2)
255 return std::end(range2);
261 ML_UTILS_END_NAMESPACE
pointer operator->() const
reference operator*() const
friend bool operator==(const iterator &x, const iterator &y)
const pointer const_pointer
ptrdiff_t difference_type
friend bool operator!=(const iterator &x, const iterator &y)
std::bidirectional_iterator_tag iterator_category
iterator(iterator &&)=default
const reference const_reference
iterator(const iterator &)=default
iterator & operator=(iterator &&)=default
typename ContainerProxy::value_type value_type
iterator & operator=(const iterator &)=default
iterator(const ContainerProxy &proxy, I index)
This template implements a proxy for containers that contain a collection of items normally accessed ...
ContainerProxy(const T &object)
const_iterator cend() const
ContainerProxy & operator=(ContainerProxy &&)=default
ContainerProxy & operator=(const ContainerProxy &)=default
ContainerProxy(ContainerProxy &&)=default
const_iterator cbegin() const
ContainerProxy(const ContainerProxy &)=default
T operator*(const FloatingPointVector< T, size, DataContainer > &a, const FloatingPointVector< T, size, DataContainer > &b)
Dot product, returns a.dot(b).
constexpr Range2::const_iterator is_rotated(const Range1 &range1, const Range2 &range2)
constexpr Is< T > is(T d)
In combination with the in function, it returns true if a passed value is in the set of possible valu...
constexpr bool in(Arg a, Args... args)