7#ifndef KRITA_CONTAINER_UTILS_H
8#define KRITA_CONTAINER_UTILS_H
18 if (a.size() != b.size())
return false;
20 Q_FOREACH(
const T &t, a) {
21 if (!b.contains(t))
return false;
29 std::sort(container.begin(), container.end());
30 auto newEnd = std::unique(container.begin(), container.end());
32 while (newEnd != container.end()) {
33 newEnd = container.erase(newEnd);
38template <
class C,
typename KeepIfFunction>
40 ->
decltype(bool(keepIf(container[0])),
void()) {
42 auto newEnd = std::remove_if(container.begin(), container.end(), [keepIf] (
typename C::reference
p) { return !keepIf(p); });
43 while (newEnd != container.end()) {
44 newEnd = container.erase(newEnd);
51 typedef typename std::remove_const<T>::type
test_type;
54 static constexpr bool test(
56 A const *const_pointer =
nullptr,
57 decltype(pointer->begin()) * =
nullptr,
58 decltype(pointer->end()) * =
nullptr,
59 decltype(const_pointer->begin()) * =
nullptr,
60 decltype(const_pointer->end()) * =
nullptr,
61 typename A::iterator * it =
nullptr,
62 typename A::const_iterator * constIt =
nullptr,
63 typename A::value_type * =
nullptr) {
65 typedef typename A::iterator iterator;
66 typedef typename A::const_iterator const_iterator;
67 typedef typename A::value_type value_type;
68 return std::is_same<
decltype(pointer->begin()),iterator>
::value &&
69 std::is_same<
decltype(pointer->end()),iterator>
::value &&
70 std::is_same<
decltype(const_pointer->begin()),const_iterator>
::value &&
71 std::is_same<
decltype(const_pointer->end()),const_iterator>
::value &&
72 std::is_same<
decltype(**it),value_type &>
::value &&
73 std::is_same<
decltype(**constIt),value_type
const &>
::value;
78 static constexpr bool test(...) {
82 static const bool value = test<test_type>(
nullptr);
88 typedef typename std::remove_const<T>::type
test_type;
90 template<typename A, typename R = decltype(std::declval<A&>().push_back(std::declval<typename A::value_type>()))>
91 static constexpr bool test(
A *) {
96 static constexpr bool test(...) {
100 static const bool value = test<test_type>(
nullptr);
typedef void(QOPENGLF_APIENTRYP PFNGLINVALIDATEBUFFERDATAPROC)(GLuint buffer)
auto filterContainer(C &container, KeepIfFunction keepIf) -> decltype(bool(keepIf(container[0])), void())
bool compareListsUnordered(const QList< T > &a, const QList< T > &b)
void makeContainerUnique(C &container)
static constexpr bool test(...)
static constexpr bool test(A *)
std::remove_const< T >::type test_type
std::remove_const< T >::type test_type
static constexpr bool test(...)
static constexpr bool test(A *pointer, A const *const_pointer=nullptr, decltype(pointer->begin()) *=nullptr, decltype(pointer->end()) *=nullptr, decltype(const_pointer->begin()) *=nullptr, decltype(const_pointer->end()) *=nullptr, typename A::iterator *it=nullptr, typename A::const_iterator *constIt=nullptr, typename A::value_type *=nullptr)