diff --git a/apps/essimporter/converter.cpp b/apps/essimporter/converter.cpp index 97c20f5325..d154f91ef9 100644 --- a/apps/essimporter/converter.cpp +++ b/apps/essimporter/converter.cpp @@ -104,11 +104,11 @@ namespace ESSImport esm.getSubNameIs("MAPD"); esm.getSubHeader(); data.resize(esm.getSubSize()); - esm.getExact(&data[0], data.size()); + esm.getExact(data.data(), data.size()); mGlobalMapImage = new osg::Image; mGlobalMapImage->allocateImage(maph.size, maph.size, 1, GL_RGB, GL_UNSIGNED_BYTE); - memcpy(mGlobalMapImage->data(), &data[0], data.size()); + memcpy(mGlobalMapImage->data(), data.data(), data.size()); // to match openmw size // FIXME: filtering? @@ -135,7 +135,7 @@ namespace ESSImport data.resize(width*height*4, 0); image2->allocateImage(width, height, 1, GL_RGBA, GL_UNSIGNED_BYTE); - memcpy(image2->data(), &data[0], data.size()); + memcpy(image2->data(), data.data(), data.size()); for (const auto & exploredCell : mContext->mExploredCells) { diff --git a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp index 9d03314d8d..e10273952a 100644 --- a/apps/openmw/mwdialogue/dialoguemanagerimp.cpp +++ b/apps/openmw/mwdialogue/dialoguemanagerimp.cpp @@ -248,7 +248,7 @@ namespace MWDialogue MWScript::InterpreterContext interpreterContext(&actor.getRefData().getLocals(), actor); Interpreter::Interpreter interpreter; MWScript::installOpcodes (interpreter); - interpreter.run (&code[0], code.size(), interpreterContext); + interpreter.run (code.data(), code.size(), interpreterContext); } catch (const std::exception& error) { diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 60c96b4f90..35b61f21e1 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -210,7 +210,7 @@ namespace MWGui MWScript::installOpcodes (interpreter, mConsoleOnlyScripts); std::vector code; output.getCode (code); - interpreter.run (&code[0], code.size(), interpreterContext); + interpreter.run (code.data(), code.size(), interpreterContext); } catch (const std::exception& error) { diff --git a/apps/openmw/mwrender/localmap.cpp b/apps/openmw/mwrender/localmap.cpp index 63784d2dae..0f433c4d05 100644 --- a/apps/openmw/mwrender/localmap.cpp +++ b/apps/openmw/mwrender/localmap.cpp @@ -591,7 +591,7 @@ void LocalMap::MapSegment::initFogOfWar() std::vector data; data.resize(sFogOfWarResolution*sFogOfWarResolution, 0xff000000); - memcpy(mFogOfWarImage->data(), &data[0], data.size()*4); + memcpy(mFogOfWarImage->data(), data.data(), data.size()*4); createFogOfWarTexture(); } @@ -612,7 +612,7 @@ void LocalMap::MapSegment::loadFogOfWar(const ESM::FogTexture &esm) return; } - Files::IMemStream in(&data[0], data.size()); + Files::IMemStream in(data.data(), data.size()); osgDB::ReaderWriter::ReadResult result = readerwriter->readImage(in); if (!result.success()) diff --git a/apps/openmw/mwstate/character.cpp b/apps/openmw/mwstate/character.cpp index 8763cf6039..7845567194 100644 --- a/apps/openmw/mwstate/character.cpp +++ b/apps/openmw/mwstate/character.cpp @@ -132,7 +132,7 @@ const MWState::Slot *MWState::Character::createSlot (const ESM::SavedGame& profi void MWState::Character::deleteSlot (const Slot *slot) { - int index = slot - &mSlots[0]; + int index = slot - mSlots.data(); if (index<0 || index>=static_cast (mSlots.size())) { @@ -147,7 +147,7 @@ void MWState::Character::deleteSlot (const Slot *slot) const MWState::Slot *MWState::Character::updateSlot (const Slot *slot, const ESM::SavedGame& profile) { - int index = slot - &mSlots[0]; + int index = slot - mSlots.data(); if (index<0 || index>=static_cast (mSlots.size())) { diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 0dba4860f5..489f80ed20 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -1148,7 +1148,7 @@ namespace MWWorld { std::vector vec; vec.emplace_back(pos, gridCenterToBounds(getNewGridCenter(pos))); - mPreloader->abortTerrainPreloadExcept(&vec[0]); + mPreloader->abortTerrainPreloadExcept(vec.data()); mPreloader->setTerrainPreloadPositions(vec); if (!sync) return; diff --git a/components/bsa/compressedbsafile.cpp b/components/bsa/compressedbsafile.cpp index e903a44dd9..2d553b0986 100644 --- a/components/bsa/compressedbsafile.cpp +++ b/components/bsa/compressedbsafile.cpp @@ -245,7 +245,7 @@ void CompressedBSAFile::readHeader() if ((archiveFlags & 0x2) != 0) { mStringBuf.resize(totalFileNameLength); - input.read(&mStringBuf[0], mStringBuf.size()); // TODO: maybe useful in building a lookup map? + input.read(mStringBuf.data(), mStringBuf.size()); // TODO: maybe useful in building a lookup map? } size_t mStringBuffOffset = 0; diff --git a/components/esm/reader.cpp b/components/esm/reader.cpp index 0e2e9a9b8a..5fafbb45ee 100644 --- a/components/esm/reader.cpp +++ b/components/esm/reader.cpp @@ -58,7 +58,7 @@ namespace ESM newSize -= 1; // don't read the null terminator yet str.resize(newSize); // assumed C++11 - stream.read(&str[0], newSize); + stream.read(str.data(), newSize); if (static_cast(stream.gcount()) == newSize) { if (hasNull) diff --git a/components/esm3/fogstate.cpp b/components/esm3/fogstate.cpp index 8b072d1ce9..948e0c49b4 100644 --- a/components/esm3/fogstate.cpp +++ b/components/esm3/fogstate.cpp @@ -28,7 +28,7 @@ void convertFogOfWar(std::vector& imageData) return; } - Files::IMemStream in(&imageData[0], imageData.size()); + Files::IMemStream in(imageData.data(), imageData.size()); osgDB::ReaderWriter::ReadResult result = tgaReader->readImage(in); if (!result.success()) diff --git a/components/esm3/globalmap.cpp b/components/esm3/globalmap.cpp index 8a0dc016b5..6a884c23a6 100644 --- a/components/esm3/globalmap.cpp +++ b/components/esm3/globalmap.cpp @@ -13,7 +13,7 @@ void GlobalMap::load (ESMReader &esm) esm.getSubNameIs("DATA"); esm.getSubHeader(); mImageData.resize(esm.getSubSize()); - esm.getExact(&mImageData[0], mImageData.size()); + esm.getExact(mImageData.data(), mImageData.size()); while (esm.isNextSub("MRK_")) { @@ -30,7 +30,7 @@ void GlobalMap::save (ESMWriter &esm) const esm.writeHNT("BNDS", mBounds); esm.startSubRecord("DATA"); - esm.write(&mImageData[0], mImageData.size()); + esm.write(mImageData.data(), mImageData.size()); esm.endRecord("DATA"); for (std::set::const_iterator it = mMarkers.begin(); it != mMarkers.end(); ++it) diff --git a/components/esm4/loadaloc.cpp b/components/esm4/loadaloc.cpp index b14341f682..29defdef23 100644 --- a/components/esm4/loadaloc.cpp +++ b/components/esm4/loadaloc.cpp @@ -118,7 +118,7 @@ void ESM4::MediaLocationController::load(ESM4::Reader& reader) { #if 0 boost::scoped_array mDataBuf(new unsigned char[subHdr.dataSize]); - reader.get(&mDataBuf[0], subHdr.dataSize); + reader.get(mDataBuf.get(), subHdr.dataSize); std::ostringstream ss; ss << mEditorId << " " << ESM::printName(subHdr.typeId) << ":size " << subHdr.dataSize << "\n"; diff --git a/components/esm4/loadnpc.cpp b/components/esm4/loadnpc.cpp index a05bedd90e..7c3597b029 100644 --- a/components/esm4/loadnpc.cpp +++ b/components/esm4/loadnpc.cpp @@ -231,7 +231,7 @@ void ESM4::Npc::load(ESM4::Reader& reader) { #if 1 boost::scoped_array dataBuf(new unsigned char[subHdr.dataSize]); - reader.get(&dataBuf[0], subHdr.dataSize); + reader.get(dataBuf.get(), subHdr.dataSize); std::ostringstream ss; ss << mEditorId << " " << ESM::printName(subHdr.typeId) << ":size " << subHdr.dataSize << "\n"; diff --git a/components/esm4/loadpgrd.cpp b/components/esm4/loadpgrd.cpp index d1b9f6d57f..d1c3a8f1c8 100644 --- a/components/esm4/loadpgrd.cpp +++ b/components/esm4/loadpgrd.cpp @@ -125,7 +125,7 @@ void ESM4::Pathgrid::load(ESM4::Reader& reader) { #if 0 boost::scoped_array mDataBuf(new unsigned char[subHdr.dataSize]); - reader.get(&mDataBuf[0], subHdr.dataSize); + reader.get(mDataBuf.get(), subHdr.dataSize); std::ostringstream ss; ss << mEditorId << " " << ESM::printName(subHdr.typeId) << ":size " << subHdr.dataSize << "\n"; diff --git a/components/esm4/loadrace.cpp b/components/esm4/loadrace.cpp index 142cfd2adf..5cf1d9a59a 100644 --- a/components/esm4/loadrace.cpp +++ b/components/esm4/loadrace.cpp @@ -110,7 +110,7 @@ void ESM4::Race::load(ESM4::Reader& reader) // 00 00 00 00 9a 99 99 3e 00 00 a0 40 02 00 00 00 #if 0 unsigned char mDataBuf[256/*bufSize*/]; - reader.get(&mDataBuf[0], subHdr.dataSize); + reader.get(mDataBuf, subHdr.dataSize); std::ostringstream ss; ss << ESM::printName(subHdr.typeId) << ":size " << subHdr.dataSize << "\n"; diff --git a/components/esm4/loadscpt.cpp b/components/esm4/loadscpt.cpp index 4c606e3351..4aa0710440 100644 --- a/components/esm4/loadscpt.cpp +++ b/components/esm4/loadscpt.cpp @@ -56,7 +56,7 @@ void ESM4::Script::load(ESM4::Reader& reader) // For debugging only #if 0 unsigned char mDataBuf[256/*bufSize*/]; - reader.get(&mDataBuf[0], subHdr.dataSize); + reader.get(mDataBuf, subHdr.dataSize); std::ostringstream ss; for (unsigned int i = 0; i < subHdr.dataSize; ++i) @@ -94,7 +94,7 @@ void ESM4::Script::load(ESM4::Reader& reader) std::cout << mEditorId << std::endl; unsigned char mDataBuf[4096/*bufSize*/]; - reader.get(&mDataBuf[0], subHdr.dataSize); + reader.get(mDataBuf, subHdr.dataSize); std::ostringstream ss; for (unsigned int i = 0; i < subHdr.dataSize; ++i) diff --git a/components/files/constrainedfilestreambuf.cpp b/components/files/constrainedfilestreambuf.cpp index 5939207193..f5fd8ac394 100644 --- a/components/files/constrainedfilestreambuf.cpp +++ b/components/files/constrainedfilestreambuf.cpp @@ -27,7 +27,7 @@ namespace Files // Read in the next chunk of data, and set the read pointers on success // Failure will throw exception. const std::size_t got = File::read(mFile, mBuffer, toRead); - setg(&mBuffer[0], &mBuffer[0], &mBuffer[0] + got); + setg(mBuffer, mBuffer, mBuffer + got); } if (gptr() == egptr()) return traits_type::eof(); diff --git a/components/files/windowspath.cpp b/components/files/windowspath.cpp index 8a17acec9d..d29a275d5f 100644 --- a/components/files/windowspath.cpp +++ b/components/files/windowspath.cpp @@ -121,9 +121,9 @@ boost::filesystem::path WindowsPath::getInstallPath() const std::vector buf(512); int len = 512; - if (RegQueryValueEx(hKey, TEXT("Installed Path"), nullptr, nullptr, (LPBYTE)&buf[0], (LPDWORD)&len) == ERROR_SUCCESS) + if (RegQueryValueEx(hKey, TEXT("Installed Path"), nullptr, nullptr, (LPBYTE)buf.data(), (LPDWORD)&len) == ERROR_SUCCESS) { - installPath = &buf[0]; + installPath = buf.data(); } RegCloseKey(hKey); } diff --git a/components/fontloader/fontloader.cpp b/components/fontloader/fontloader.cpp index 935667e376..a06429ed4b 100644 --- a/components/fontloader/fontloader.cpp +++ b/components/fontloader/fontloader.cpp @@ -386,7 +386,7 @@ namespace Gui std::vector textureData; textureData.resize(width*height*4); - bitmapFile->read(&textureData[0], width*height*4); + bitmapFile->read(textureData.data(), width*height*4); if (!bitmapFile->good()) fail(*bitmapFile, bitmapFilename, "File too small to be a valid bitmap"); bitmapFile.reset(); @@ -394,7 +394,7 @@ namespace Gui MyGUI::ITexture* tex = MyGUI::RenderManager::getInstance().createTexture(bitmapFilename); tex->createManual(width, height, MyGUI::TextureUsage::Write, MyGUI::PixelFormat::R8G8B8A8); unsigned char* texData = reinterpret_cast(tex->lock(MyGUI::TextureUsage::Write)); - memcpy(texData, &textureData[0], textureData.size()); + memcpy(texData, textureData.data(), textureData.size()); tex->unlock(); // We need to emulate loading from XML because the data members are private as of mygui 3.2.0 diff --git a/components/l10n/messagebundles.cpp b/components/l10n/messagebundles.cpp index 6934dcaad8..d44c5b34a1 100644 --- a/components/l10n/messagebundles.cpp +++ b/components/l10n/messagebundles.cpp @@ -138,7 +138,7 @@ namespace l10n if (message) { if (!args.empty() && !argNames.empty()) - message->format(&argNames[0], &args[0], args.size(), result, success); + message->format(argNames.data(), args.data(), args.size(), result, success); else message->format(nullptr, nullptr, args.size(), result, success); checkSuccess(success, std::string("Failed to format message ") + key.data()); @@ -158,7 +158,7 @@ namespace l10n return std::string(key); if (!args.empty() && !argNames.empty()) - defaultMessage.format(&argNames[0], &args[0], args.size(), result, success); + defaultMessage.format(argNames.data(), args.data(), args.size(), result, success); else defaultMessage.format(nullptr, nullptr, args.size(), result, success); checkSuccess(success, std::string("Failed to format message ") + key.data());