19ML_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...);
63 template <
class T,
class R,
typename I, I (T::*Count)() const, R *(T::*Access)(I) const>
107 return (_proxy->_object->*Access)(_index);
143 return x._proxy == y._proxy && x._index == y._index;
166 return iterator(*
this, (_object->*Count)());
189 template <
typename Range1,
typename Range2,
typename BinaryPredicate>
190 constexpr typename Range2::const_iterator
is_rotated(
const Range1 &range1,
const Range2 &range2,
193 if (std::size(range1) != std::size(range2))
195 return std::end(range2);
197 if (std::size(range1) == 0)
199 return std::end(range2);
201 const auto itFind2 = std::find_if(std::begin(range2), std::end(range2),
202 [p, &range1](
const auto &v) {
return p(*begin(range1), v); });
204 if (itFind2 == std::end(range2))
206 return std::end(range2);
209 std::mismatch(itFind2, std::end(range2), std::begin(range1), std::end(range1), p);
210 if (resultIts.first != std::end(range2))
212 return std::end(range2);
214 resultIts = std::mismatch(std::begin(range2), itFind2, resultIts.second, std::end(range1), p);
215 if (resultIts.first != itFind2)
217 return std::end(range2);
229 template <
typename Range1,
typename Range2>
230 constexpr typename Range2::const_iterator
is_rotated(
const Range1 &range1,
const Range2 &range2)
232 if (std::size(range1) != std::size(range2))
234 return std::end(range2);
236 if (std::size(range1) == 0)
238 return std::end(range2);
240 const auto itFind2 = std::find(std::begin(range2), std::end(range2), *begin(range1));
242 if (itFind2 == std::end(range2))
244 return std::end(range2);
246 auto resultIts = std::mismatch(itFind2, std::end(range2), std::begin(range1), std::end(range1));
247 if (resultIts.first != std::end(range2))
249 return std::end(range2);
251 resultIts = std::mismatch(std::begin(range2), itFind2, resultIts.second, std::end(range1));
252 if (resultIts.first != itFind2)
254 return std::end(range2);
260ML_UTILS_END_NAMESPACE
pointer operator->() const
reference operator*() const
friend bool operator==(const iterator &x, const iterator &y)
const pointer const_pointer
iterator & operator=(const iterator &)=default
ptrdiff_t difference_type
iterator & operator=(iterator &&)=default
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
typename ContainerProxy::value_type value_type
iterator(const ContainerProxy &proxy, I index)
This template implements a proxy for container that contain a collection of items that are normally a...
ContainerProxy(const T &object)
const_iterator cend() const
ContainerProxy(ContainerProxy &&)=default
ContainerProxy & operator=(ContainerProxy &&)=default
const_iterator cbegin() const
ContainerProxy(const ContainerProxy &)=default
ContainerProxy & operator=(const ContainerProxy &)=default
T operator*(const FloatingPointVector< T, size, DataContainer > &a, const FloatingPointVector< T, size, DataContainer > &b)
Dot product, returns a.dot(b).
constexpr Is< T > is(T d)
constexpr Range2::const_iterator is_rotated(const Range1 &range1, const Range2 &range2, BinaryPredicate p)
In combination with the in function it returns true, if a passed values is one of a set of possible v...
constexpr bool in(Arg a, Args... args)