本文整理汇总了C++中qMove函数的典型用法代码示例。如果您正苦于以下问题:C++ qMove函数的具体用法?C++ qMove怎么用?C++ qMove使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了qMove函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QFETCH
void tst_QAtomicIntegerXX::assign()
{
QFETCH(LargeInt, value);
QAtomicInteger<T> atomic(value);
QAtomicInteger<T> copy;
copy = atomic;
QCOMPARE(copy.load(), atomic.load());
QAtomicInteger<T> copy2;
copy2 = atomic; // operator=(const QAtomicInteger &)
QCOMPARE(copy2.load(), atomic.load());
QAtomicInteger<T> copy2bis;
copy2bis = atomic.load(); // operator=(T)
QCOMPARE(copy2bis.load(), atomic.load());
// move
QAtomicInteger<T> copy3;
copy3 = qMove(copy);
QCOMPARE(copy3.load(), atomic.load());
QAtomicInteger<T> copy4;
copy4 = qMove(copy2);
QCOMPARE(copy4.load(), atomic.load());
}
示例2: p1
void tst_QPen::move_assign()
{
QPen p1(Qt::black), p2(Qt::white);
// check that moving does the right thing:
p2 = qMove(p1); // could be move or copy assignment, so don't check p1's state
QCOMPARE(p2.color(), QColor(Qt::black));
// check that move-assigned-from QPen p1 can still be used, albeit
// with undocumented state (it's p2's original state):
QVERIFY(p1.style() != Qt::NoPen);
// check that moved-from QPen p1 can still be safely copied:
const QPen p3 = p1;
// check that moved-from QPen p1 can still be safely assigned to:
const QPen p4(Qt::yellow);
p1 = p4;
QCOMPARE(p1.color(), QColor(Qt::yellow));
// check that moved-from QPens p2, p3 can still be safely destroyed:
QPen p5;
p5 = qMove(p2);
// intentionally no more statements beyond this point
}
示例3: src
void tst_QPalette::moveSemantics()
{
#ifdef Q_COMPILER_RVALUE_REFS
QPalette src(Qt::red), dst;
const QPalette control = src;
QVERIFY(src != dst);
QCOMPARE(src, control);
QVERIFY(!dst.isCopyOf(src));
QVERIFY(!dst.isCopyOf(control));
dst = qMove(src); // move assignment
QVERIFY(!dst.isCopyOf(src)); // isCopyOf() works on moved-from palettes, too
QVERIFY(dst.isCopyOf(control));
QCOMPARE(dst, control);
src = control; // check moved-from 'src' can still be assigned to (doesn't crash)
QVERIFY(src.isCopyOf(dst));
QVERIFY(src.isCopyOf(control));
QPalette dst2(qMove(src)); // move construction
QVERIFY(!src.isCopyOf(dst));
QVERIFY(!src.isCopyOf(dst2));
QVERIFY(!src.isCopyOf(control));
QCOMPARE(dst2, control);
QVERIFY(dst2.isCopyOf(dst));
QVERIFY(dst2.isCopyOf(control));
// check moved-from 'src' can still be destroyed (doesn't crash)
#else
QSKIP("Compiler doesn't support C++11 move semantics");
#endif
}
示例4: LogPrintf
bool OsmAnd::MapRendererKeyedSymbolsResource::uploadToGPU()
{
bool ok;
bool anyUploadFailed = false;
const auto link_ = link.lock();
const auto collection = static_cast<MapRendererKeyedResourcesCollection*>(&link_->collection);
QHash< std::shared_ptr<MapSymbol>, std::shared_ptr<const GPUAPI::ResourceInGPU> > uploaded;
for (const auto& symbol : constOf(_sourceData->symbolsGroup->symbols))
{
// Prepare data and upload to GPU
std::shared_ptr<const GPUAPI::ResourceInGPU> resourceInGPU;
ok = resourcesManager->uploadSymbolToGPU(symbol, resourceInGPU);
// If upload have failed, stop
if (!ok)
{
LogPrintf(LogSeverityLevel::Error, "Failed to upload keyed symbol");
anyUploadFailed = true;
break;
}
// Mark this symbol as uploaded
uploaded.insert(symbol, qMove(resourceInGPU));
}
// If at least one symbol failed to upload, consider entire tile as failed to upload,
// and unload its partial GPU resources
if (anyUploadFailed)
{
uploaded.clear();
return false;
}
// All resources have been uploaded to GPU successfully by this point
_retainableCacheMetadata = _sourceData->retainableCacheMetadata;
_sourceData.reset();
for (const auto& entry : rangeOf(constOf(uploaded)))
{
const auto& symbol = entry.key();
auto& resource = entry.value();
// Unload GPU data from symbol, since it's uploaded already
resourcesManager->releaseGpuUploadableDataFrom(symbol);
// Move reference
_resourcesInGPU.insert(symbol, qMove(resource));
}
return true;
}
示例5: LogPrintf
OSMAND_CORE_API QString OSMAND_CORE_CALL OsmAnd::ICU::transliterateToLatin(
const QString& input,
const bool keepAccentsAndDiacriticsInInput /*= true*/,
const bool keepAccentsAndDiacriticsInOutput /*= true*/)
{
QString output;
UErrorCode icuError = U_ZERO_ERROR;
bool ok = true;
const auto pAnyToLatinTransliterator = g_pIcuAnyToLatinTransliterator->clone();
if (pAnyToLatinTransliterator == nullptr || U_FAILURE(icuError))
{
LogPrintf(LogSeverityLevel::Error, "ICU error: %d", icuError);
if (pAnyToLatinTransliterator != nullptr)
delete pAnyToLatinTransliterator;
return input;
}
// Transliterate from any to latin
UnicodeString icuString(reinterpret_cast<const UChar*>(input.unicode()), input.length());
pAnyToLatinTransliterator->transliterate(icuString);
output = qMove(QString(reinterpret_cast<const QChar*>(icuString.getBuffer()), icuString.length()));
// If input and output differ at this point or accents/diacritics should be converted,
// normalize the output again
if ((input.compare(output, Qt::CaseInsensitive) != 0 || !keepAccentsAndDiacriticsInInput) && !keepAccentsAndDiacriticsInOutput)
{
const auto pIcuAccentsAndDiacriticsConverter = g_pIcuAccentsAndDiacriticsConverter->clone();
ok = pIcuAccentsAndDiacriticsConverter != nullptr && U_SUCCESS(icuError);
if (ok)
{
pIcuAccentsAndDiacriticsConverter->transliterate(icuString);
output = qMove(QString(reinterpret_cast<const QChar*>(icuString.getBuffer()), icuString.length()));
}
if (pIcuAccentsAndDiacriticsConverter != nullptr)
delete pIcuAccentsAndDiacriticsConverter;
}
if (pAnyToLatinTransliterator != nullptr)
delete pAnyToLatinTransliterator;
if (!ok)
{
LogPrintf(LogSeverityLevel::Error, "ICU error: %d", icuError);
return input;
}
return output;
}
示例6: collectSources
std::shared_ptr<OsmAnd::ObfDataInterface> OsmAnd::ObfsCollection_P::obtainDataInterface() const
{
// Check if sources were invalidated
if (_collectedSourcesInvalidated.loadAcquire() > 0)
collectSources();
// Create ObfReaders from collected sources
QList< std::shared_ptr<const ObfReader> > obfReaders;
{
QReadLocker scopedLocker(&_collectedSourcesLock);
for(const auto& collectedSources : constOf(_collectedSources))
{
obfReaders.reserve(obfReaders.size() + collectedSources.size());
for(const auto& obfFile : constOf(collectedSources))
{
std::shared_ptr<const ObfReader> obfReader(new ObfReader(obfFile));
if (!obfReader->isOpened() || !obfReader->obtainInfo())
continue;
obfReaders.push_back(qMove(obfReader));
}
}
}
return std::shared_ptr<ObfDataInterface>(new ObfDataInterface(obfReaders));
}
示例7: scopedLocker
OsmAnd::ObfsCollection::SourceOriginId OsmAnd::ObfsCollection_P::addDirectory(const QDir& dir, bool recursive)
{
QWriteLocker scopedLocker(&_sourcesOriginsLock);
const auto allocatedId = _lastUnusedSourceOriginId++;
auto sourceOrigin = new DirectoryAsSourceOrigin();
sourceOrigin->directory = dir;
sourceOrigin->isRecursive = recursive;
_sourcesOrigins.insert(allocatedId, qMove(std::shared_ptr<const SourceOrigin>(sourceOrigin)));
_fileSystemWatcher->addPath(dir.canonicalPath());
if (recursive)
{
QFileInfoList subdirs;
Utilities::findDirectories(dir, QStringList() << QLatin1String("*"), subdirs, true);
for(const auto& subdir : subdirs)
{
const auto canonicalPath = subdir.canonicalFilePath();
sourceOrigin->watchedSubdirectories.insert(canonicalPath);
_fileSystemWatcher->addPath(canonicalPath);
}
}
invalidateCollectedSources();
return allocatedId;
}
示例8: isNull
/*!
\fn QVersionNumber QVersionNumber::fromString(const QString &string,
int *suffixIndex)
Constructs a QVersionNumber from a specially formatted \a string of
non-negative decimal numbers delimited by '.'.
Once the numerical segments have been parsed, the remainder of the string
is considered to be the suffix string. The start index of that string will be
stored in \a suffixIndex if it is not null.
\snippet qversionnumber/main.cpp 3
\sa isNull()
*/
QVersionNumber QVersionNumber::fromString(const QString &string, int *suffixIndex)
{
QVector<int> seg;
const QByteArray cString(string.toLatin1());
const char *start = cString.constData();
const char *end = start;
const char *lastGoodEnd = start;
const char *endOfString = cString.constData() + cString.size();
do {
bool ok = false;
const qulonglong value = qstrtoull(start, &end, 10, &ok);
if (!ok || value > qulonglong(std::numeric_limits<int>::max()))
break;
seg.append(int(value));
start = end + 1;
lastGoodEnd = end;
} while (start < endOfString && (end < endOfString && *end == '.'));
if (suffixIndex)
*suffixIndex = int(lastGoodEnd - cString.constData());
return QVersionNumber(qMove(seg));
}
示例9: encodeRuleId
bool OsmAnd::MapStyle_P::registerRule( MapStyleRulesetType type, const std::shared_ptr<MapStyleRule>& rule )
{
MapStyleValue tagData;
if(!rule->getAttribute(_builtinValueDefs->INPUT_TAG, tagData))
{
OsmAnd::LogPrintf(OsmAnd::LogSeverityLevel::Error, "Attribute tag should be specified for root filter");
return false;
}
MapStyleValue valueData;
if(!rule->getAttribute(_builtinValueDefs->INPUT_VALUE, valueData))
{
OsmAnd::LogPrintf(OsmAnd::LogSeverityLevel::Error, "Attribute tag should be specified for root filter");
return false;
}
uint64_t id = encodeRuleId(tagData.asSimple.asUInt, valueData.asSimple.asUInt);
auto insertedRule = rule;
auto& ruleset = obtainRulesRef(type);
auto itPrevious = ruleset.constFind(id);
if(itPrevious != ruleset.cend())
{
// all root rules should have at least tag/value
insertedRule = createTagValueRootWrapperRule(id, *itPrevious);
insertedRule->_d->_ifElseChildren.push_back(rule);
}
ruleset.insert(id, qMove(insertedRule));
return true;
}
示例10: qMove
void MachineModel::specialMoveY(const float& y, const float& feed)
{
FloatPoint sp = localPosition;
sp.y = y;
sp.f = feed;
qMove(sp);
}
示例11: constOf
bool OsmAnd::MapRendererTiledResourcesCollection::updateCollectionSnapshot() const
{
const auto invalidatesDiscarded = _collectionSnapshotInvalidatesCount.fetchAndAddOrdered(0);
if (invalidatesDiscarded == 0)
return true;
// Copy from original storage to temp storage
Storage storageCopy;
{
if (!_collectionLock.tryLockForRead())
return false;
for (int zoomLevel = MinZoomLevel; zoomLevel <= MaxZoomLevel; zoomLevel++)
{
const auto& sourceStorageLevel = constOf(_storage)[zoomLevel];
auto& targetStorageLevel = storageCopy[zoomLevel];
targetStorageLevel = detachedOf(sourceStorageLevel);
}
_collectionLock.unlock();
}
_collectionSnapshotInvalidatesCount.fetchAndAddOrdered(-invalidatesDiscarded);
// Copy from temp storage to snapshot
{
QWriteLocker scopedLocker(&_snapshot->_lock);
_snapshot->_storage = qMove(storageCopy);
}
return true;
}
示例12: qMove
void OsmAnd::ICU::initialize()
{
// Initialize ICU
UErrorCode icuError = U_ZERO_ERROR;
g_IcuData = qMove(std::unique_ptr<QByteArray>(new QByteArray(EmbeddedResources::decompressResource(QLatin1String("icu4c/icu-data-l.dat")))));
udata_setCommonData(g_IcuData->constData(), &icuError);
if (U_FAILURE(icuError))
{
LogPrintf(LogSeverityLevel::Error, "Failed to initialize ICU data: %d", icuError);
return;
}
u_init(&icuError);
if (U_FAILURE(icuError))
{
LogPrintf(LogSeverityLevel::Error, "Failed to initialize ICU: %d", icuError);
return;
}
// Allocate resources:
g_pIcuAnyToLatinTransliterator = Transliterator::createInstance(UnicodeString("Any-Latin/BGN"), UTRANS_FORWARD, icuError);
if (U_FAILURE(icuError))
LogPrintf(LogSeverityLevel::Error, "Failed to create global ICU Any-to-Latin transliterator: %d", icuError);
icuError = U_ZERO_ERROR;
g_pIcuAccentsAndDiacriticsConverter = Transliterator::createInstance(UnicodeString("NFD; [:Mn:] Remove; NFC"), UTRANS_FORWARD, icuError);
if (U_FAILURE(icuError))
LogPrintf(LogSeverityLevel::Error, "Failed to create global ICU accents&diacritics converter: %d", icuError);
icuError = U_ZERO_ERROR;
g_pIcuWordBreakIterator = BreakIterator::createWordInstance(Locale::getRoot(), icuError);
if (U_FAILURE(icuError))
LogPrintf(LogSeverityLevel::Error, "Failed to create global ICU word break iterator: %d", icuError);
}
示例13: LogPrintf
OSMAND_CORE_API QString OSMAND_CORE_CALL OsmAnd::ICU::transliterateToLatin(const QString& input)
{
QString output;
UErrorCode icuError = U_ZERO_ERROR;
bool ok = true;
const auto pTransliterator = g_pIcuTransliterator->clone();
if(pTransliterator == nullptr || !U_SUCCESS(icuError))
{
LogPrintf(LogSeverityLevel::Error, "ICU error: %d", icuError);
if(pTransliterator != nullptr)
delete pTransliterator;
return input;
}
UnicodeString icuString(reinterpret_cast<const UChar*>(input.unicode()), input.length());
pTransliterator->transliterate(icuString);
output = qMove(QString(reinterpret_cast<const QChar*>(icuString.getBuffer()), icuString.length()));
if(pTransliterator != nullptr)
delete pTransliterator;
if(!ok)
{
LogPrintf(LogSeverityLevel::Error, "ICU error: %d", icuError);
return input;
}
return output;
}
示例14: recurseDirectory
void TexturePacker::pack()
{
QString basepath = Project::getActiveProject().getImagePath();
SpriteArray sprites, usedSprites;
recurseDirectory(sprites, basepath);
SpriteAtlas& atlas = Project::getActiveProject().getSpriteAtlas();
atlas.clear();
do
{
MaxRectsAlgorithm maxrects(2046, 2046);
maxrects.insert(sprites, usedSprites);
if ( !usedSprites.isEmpty() )
{
SpriteSheet sheet = createSpriteSheet(usedSprites);
atlas.append(qMove(sheet));
usedSprites.clear();
}
}
while ( !sprites.isEmpty() );
atlas.save(Project::getActiveProject().getTileAtlasPath());
}
示例15: scopedLocker
QList< std::shared_ptr<const OsmAnd::Road> > OsmAnd::CachingRoadLocator_P::findRoadsInArea(
const PointI position31,
const double radiusInMeters,
const RoutingDataLevel dataLevel) const
{
QList< std::shared_ptr<const Road> > roadsInBBox;
const auto bbox31 = (AreaI)Utilities::boundingBox31FromAreaInMeters(radiusInMeters, position31);
const auto obfDataInterface = owner->obfsCollection->obtainDataInterface(bbox31);
QList< std::shared_ptr<const ObfRoutingSectionReader::DataBlock> > referencedCacheEntries;
obfDataInterface->loadRoads(
dataLevel,
&bbox31,
&roadsInBBox,
nullptr,
nullptr,
&_cache,
&referencedCacheEntries,
nullptr,
nullptr);
{
QMutexLocker scopedLocker(&_referencedDataBlocksMapMutex);
for (auto& referencedBlock : referencedCacheEntries)
_referencedDataBlocksMap[referencedBlock.get()].push_back(qMove(referencedBlock));
}
return RoadLocator::findRoadsInArea(roadsInBBox, position31, radiusInMeters);
}