* Consistently use anyOf to implement contains.
* Support contains over an container of std::unique_ptr matching a pointer.
Change-Id: I0180f3ec3d5935d8afeeac67a745d4b38a01674d
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Add function that casts QObjects of a given container to a desired type
and return the result via the same container with the desired value
type.
Change-Id: I45949c982c8dbdd0cce069d62cd2db5c8517f9f5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Many STL algorithms have value version. So you can only use a predicate:
std::stable_partition(std::begin(list), std::end(list), [](int entry) {
return entry < 20;
});
With this predicates you can write it in a shorter form:
std::stable_partition(std::begin(list), std::end(list), lessThan(20));
The find helpers are moved to predicates too.
Change-Id: I791b3105ca84ef7c5a519d22589a91b5548cf3e4
Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Pass the mapping from custom enum to text style in form of a function,
which then can use a switch which is checked by compilers, and
avoids the need to lookup a different enum somewhere else to find
out what the mapping actually is.
That mapping is cached to keep performance as before.
Also, most highlighters created an enum just for the purpose of mapping
to text styles, basically creating duplicated subsets of text style like
enums everywhere. Instead provide a default, identity mapping from text
styles to text styles.
Change-Id: I2ea1ca702b99e36b8742dfda510b1b2753f0a1c2
Reviewed-by: David Schulz <david.schulz@qt.io>
It is seen as good practice to use Container::reserve if you know the size
in advance.
Change-Id: If1398eaa099f4d3f657778aca46516f9bdec14c9
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Avoids some code duplication. Available with C++14 / GCC>=4.9.
Change-Id: Iae90466ec9620ffc84b7a45a55490f5fbc8c5b74
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
Available now after switching to C++14 and GCC>=4.9
Change-Id: I44e9859a6abe66db16d77b228466b65eadced8ae
Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This reverts commit defb18aef4.
This reverts commit 602f8e72be.
The refactoring of transform does not compile with
MSVC2015 Update 2. Retry when we can upgrade to update 3.
Change-Id: I8bfd6ad12c71759af4840c2615d9a8f2390fd4bc
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This reverts commit 52f1fe7033.
Revert the revert, which was done because we still support
compilation of 4.1 with GCC 4.7, and that crashes with this patch.
For master/4.2 we require GCC 4.8.
Change-Id: Ifd0b8b4641fe3dd658f9bde62b9e4f888d998ee7
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This methods returns a new container with only the unique elements
in the input container. Uses == for comparison of elements.
Change-Id: I80c2027b4d275d27343bd64851c17d42bc971e82
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
These take a container and a predicate and return a Partition
struct with the hit and miss fields. Any element in the original
container will end up in either hit or miss, depending on whether
the predicate returned true for the element or not.
Change-Id: Ia02cd704d6fe1388dc677308440acc48f7c9c1e1
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Do not require containers to provide a size() method. This
makes for a less optimized insertion into the target container,
but most Qt classes should still handle this ok.
The upside is that e.g. the treemodel iterators can now be
transformed.
Change-Id: I4f149720631d9efb7b787332f039074b4c796965
Reviewed-by: Eike Ziller <eike.ziller@theqtcompany.com>
Currently e.g. this won't compile:
Utils::equal(&Class::toString, QLatin1String("xxx"));
because eqaul_to<QLatin1String> doesn't know how to compare
QString and QLatin1String.
In C++14, equal_to<> (without any template parameter) was added,
which simply works in that case.
Change-Id: I463d01e23f9f0379fea95ef1de4305751af8f1a7
Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Use a helper class so that the actual implementation is shared and
introduce a helper class for treating QStringList and other qt
containers in the same way.
There are now 2² overloads, because:
- member function pointer vs everything else
- same container type, different container types
Change-Id: I343ca7d4e0007f7146b2e646c436c22174e27779
Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
- Works for all container types now, defaulting to
the same container type for input and output
- Enables specifying the result container type,
e.g. QSet<X> x = Utils::transform<QSet>(list, function);
- Use our own inserter instead of std::back_inserter,
to enable usage with QSet<>
Change-Id: I7256e51430bfc1409456c68b6ee270778b95e9d5
Reviewed-by: hjk <hjk121@nokiamail.com>
Qt 5.3 is the minimum requirement these days. Remove all fallback code
from sources and project files.
Change-Id: If6188a471197acadda4d6baee71804ba1a8026c6
Reviewed-by: Eike Ziller <eike.ziller@digia.com>
Fix logic around temporary qt versions. We want essentially shared
ownership of kits on the temporary qt version.
Change-Id: Ic8c748aa2b04afb5a30444563b3fc2f4272ca47c
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Msvc 2013 (with update 2) had problems with using the member variant of
Utils::equal in ToolChainModel::findToolChain. This patch removes the
Utils::equal variant and does a workaround in
ToolChainModel::findToolChain
Change-Id: Ib0717fe426e34763b912e4a73db266c56aa8c1dd
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Apparently g++ 4.7 has a broken implementation of std::is_convertible.
Change-Id: I2857b265dcd70d11ead00b45e2ba096606985e63
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Takes a member (function) pointer and a value and returns a functor,
that takes a instance of the mfp's class and returns whether it's equal
to value. Sounds complicated, but is a common pattern that is easy to
understand.
Change-Id: Iaaeb90488d34ddfd6940dadd4c66705381198fee
Reviewed-by: Nikita Baryshnikov <nib952051@gmail.com>
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Add Utils::transform and anyOf that take a member function pointer.
Remove bestElementOr it's unused.
Use declval<T> in transform's return type, because msvc does evaluate
T() and for types that don't have simple constructor this fails.
Add std::remove_reference since decltype returns a reference for
lvalues.
Change-Id: I22248b226748eeb27af0d300182d574438d7f756
Reviewed-by: Eike Ziller <eike.ziller@digia.com>