From e1d3eff5870e3d61e50d32e4f564fe76143f87ef Mon Sep 17 00:00:00 2001 From: binary1248 Date: Mon, 3 Apr 2017 19:08:52 +0200 Subject: [PATCH] Replaced &container[0] with container.data() wherever applicable. --- examples/voip/Server.cpp | 2 +- src/SFML/Audio/Music.cpp | 4 +-- src/SFML/Audio/SoundBuffer.cpp | 8 +++--- src/SFML/Audio/SoundBufferRecorder.cpp | 2 +- src/SFML/Audio/SoundFileWriterFlac.cpp | 2 +- src/SFML/Audio/SoundRecorder.cpp | 4 +-- src/SFML/Graphics/Font.cpp | 4 +-- src/SFML/Graphics/Image.cpp | 10 +++---- src/SFML/Graphics/ImageLoader.cpp | 14 +++++----- src/SFML/Graphics/Shader.cpp | 34 +++++++++++------------ src/SFML/Graphics/Texture.cpp | 12 ++++---- src/SFML/Graphics/VertexArray.cpp | 2 +- src/SFML/Network/Packet.cpp | 2 +- src/SFML/Network/TcpSocket.cpp | 10 +++---- src/SFML/Network/UdpSocket.cpp | 4 +-- src/SFML/Window/FreeBSD/JoystickImpl.cpp | 6 ++-- src/SFML/Window/OSX/JoystickImpl.cpp | 4 +-- src/SFML/Window/OSX/SFContext.mm | 2 +- src/SFML/Window/Unix/GlxContext.cpp | 2 +- src/SFML/Window/Unix/WindowImplX11.cpp | 14 +++++----- src/SFML/Window/Win32/WglContext.cpp | 2 +- src/SFML/Window/Win32/WindowImplWin32.cpp | 2 +- 22 files changed, 73 insertions(+), 73 deletions(-) diff --git a/examples/voip/Server.cpp b/examples/voip/Server.cpp index 4730cb83..f1a6359d 100644 --- a/examples/voip/Server.cpp +++ b/examples/voip/Server.cpp @@ -89,7 +89,7 @@ private: } // Fill audio data to pass to the stream - data.samples = &m_tempBuffer[0]; + data.samples = m_tempBuffer.data(); data.sampleCount = m_tempBuffer.size(); // Update the playing offset diff --git a/src/SFML/Audio/Music.cpp b/src/SFML/Audio/Music.cpp index 3c3bae7f..59853951 100644 --- a/src/SFML/Audio/Music.cpp +++ b/src/SFML/Audio/Music.cpp @@ -113,8 +113,8 @@ bool Music::onGetData(SoundStream::Chunk& data) std::lock_guard lock(m_mutex); // Fill the chunk parameters - data.samples = &m_samples[0]; - data.sampleCount = static_cast(m_file.read(&m_samples[0], m_samples.size())); + data.samples = m_samples.data(); + data.sampleCount = static_cast(m_file.read(m_samples.data(), m_samples.size())); // Check if we have stopped obtaining samples or reached the end of the audio file return (data.sampleCount != 0) && (m_file.getSampleOffset() < m_file.getSampleCount()); diff --git a/src/SFML/Audio/SoundBuffer.cpp b/src/SFML/Audio/SoundBuffer.cpp index f412a125..9ccc13bd 100644 --- a/src/SFML/Audio/SoundBuffer.cpp +++ b/src/SFML/Audio/SoundBuffer.cpp @@ -148,7 +148,7 @@ bool SoundBuffer::saveToFile(const std::string& filename) const if (file.openFromFile(filename, getSampleRate(), getChannelCount())) { // Write the samples to the opened file - file.write(&m_samples[0], m_samples.size()); + file.write(m_samples.data(), m_samples.size()); return true; } @@ -162,7 +162,7 @@ bool SoundBuffer::saveToFile(const std::string& filename) const //////////////////////////////////////////////////////////// const Int16* SoundBuffer::getSamples() const { - return m_samples.empty() ? NULL : &m_samples[0]; + return m_samples.empty() ? NULL : m_samples.data(); } @@ -224,7 +224,7 @@ bool SoundBuffer::initialize(InputSoundFile& file) // Read the samples from the provided file m_samples.resize(static_cast(sampleCount)); - if (file.read(&m_samples[0], sampleCount) == sampleCount) + if (file.read(m_samples.data(), sampleCount) == sampleCount) { // Update the internal buffer with the new samples return update(channelCount, sampleRate); @@ -262,7 +262,7 @@ bool SoundBuffer::update(unsigned int channelCount, unsigned int sampleRate) // Fill the buffer ALsizei size = static_cast(m_samples.size()) * sizeof(Int16); - alCheck(alBufferData(m_buffer, format, &m_samples[0], size, sampleRate)); + alCheck(alBufferData(m_buffer, format, m_samples.data(), size, sampleRate)); // Compute the duration m_duration = seconds(static_cast(m_samples.size()) / sampleRate / channelCount); diff --git a/src/SFML/Audio/SoundBufferRecorder.cpp b/src/SFML/Audio/SoundBufferRecorder.cpp index 105b45b6..486cfec6 100644 --- a/src/SFML/Audio/SoundBufferRecorder.cpp +++ b/src/SFML/Audio/SoundBufferRecorder.cpp @@ -63,7 +63,7 @@ bool SoundBufferRecorder::onProcessSamples(const Int16* samples, std::size_t sam void SoundBufferRecorder::onStop() { if (!m_samples.empty()) - m_buffer.loadFromSamples(&m_samples[0], m_samples.size(), getChannelCount(), getSampleRate()); + m_buffer.loadFromSamples(m_samples.data(), m_samples.size(), getChannelCount(), getSampleRate()); } diff --git a/src/SFML/Audio/SoundFileWriterFlac.cpp b/src/SFML/Audio/SoundFileWriterFlac.cpp index b12088b0..b72ee0d5 100644 --- a/src/SFML/Audio/SoundFileWriterFlac.cpp +++ b/src/SFML/Audio/SoundFileWriterFlac.cpp @@ -105,7 +105,7 @@ void SoundFileWriterFlac::write(const Int16* samples, Uint64 count) m_samples32.assign(samples, samples + frames * m_channelCount); // Write them to the FLAC stream - FLAC__stream_encoder_process_interleaved(m_encoder, &m_samples32[0], frames); + FLAC__stream_encoder_process_interleaved(m_encoder, m_samples32.data(), frames); // Next chunk count -= m_samples32.size(); diff --git a/src/SFML/Audio/SoundRecorder.cpp b/src/SFML/Audio/SoundRecorder.cpp index 0e41f27d..f139d67e 100644 --- a/src/SFML/Audio/SoundRecorder.cpp +++ b/src/SFML/Audio/SoundRecorder.cpp @@ -310,10 +310,10 @@ void SoundRecorder::processCapturedSamples() { // Get the recorded samples m_samples.resize(samplesAvailable * getChannelCount()); - alcCaptureSamples(captureDevice, &m_samples[0], samplesAvailable); + alcCaptureSamples(captureDevice, m_samples.data(), samplesAvailable); // Forward them to the derived class - if (!onProcessSamples(&m_samples[0], m_samples.size())) + if (!onProcessSamples(m_samples.data(), m_samples.size())) { // The user wants to stop the capture m_isCapturing = false; diff --git a/src/SFML/Graphics/Font.cpp b/src/SFML/Graphics/Font.cpp index 4829a526..ec82080f 100644 --- a/src/SFML/Graphics/Font.cpp +++ b/src/SFML/Graphics/Font.cpp @@ -585,7 +585,7 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f // Resize the pixel buffer to the new size and fill it with transparent white pixels m_pixelBuffer.resize(width * height * 4); - Uint8* current = &m_pixelBuffer[0]; + Uint8* current = m_pixelBuffer.data(); Uint8* end = current + width * height * 4; while (current != end) @@ -632,7 +632,7 @@ Glyph Font::loadGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, f unsigned int y = glyph.textureRect.top - padding; unsigned int w = glyph.textureRect.width + 2 * padding; unsigned int h = glyph.textureRect.height + 2 * padding; - page.texture.update(&m_pixelBuffer[0], w, h, x, y); + page.texture.update(m_pixelBuffer.data(), w, h, x, y); } // Delete the FT glyph diff --git a/src/SFML/Graphics/Image.cpp b/src/SFML/Graphics/Image.cpp index 8fc77a1b..00bb1a7e 100644 --- a/src/SFML/Graphics/Image.cpp +++ b/src/SFML/Graphics/Image.cpp @@ -57,7 +57,7 @@ void Image::create(unsigned int width, unsigned int height, const Color& color) std::vector newPixels(width * height * 4); // Fill it with the specified color - Uint8* ptr = &newPixels[0]; + Uint8* ptr = newPixels.data(); Uint8* end = ptr + newPixels.size(); while (ptr < end) { @@ -164,7 +164,7 @@ void Image::createMaskFromColor(const Color& color, Uint8 alpha) if (!m_pixels.empty()) { // Replace the alpha of the pixels that match the transparent color - Uint8* ptr = &m_pixels[0]; + Uint8* ptr = m_pixels.data(); Uint8* end = ptr + m_pixels.size(); while (ptr < end) { @@ -215,8 +215,8 @@ void Image::copy(const Image& source, unsigned int destX, unsigned int destY, co int rows = height; int srcStride = source.m_size.x * 4; int dstStride = m_size.x * 4; - const Uint8* srcPixels = &source.m_pixels[0] + (srcRect.left + srcRect.top * source.m_size.x) * 4; - Uint8* dstPixels = &m_pixels[0] + (destX + destY * m_size.x) * 4; + const Uint8* srcPixels = source.m_pixels.data() + (srcRect.left + srcRect.top * source.m_size.x) * 4; + Uint8* dstPixels = m_pixels.data() + (destX + destY * m_size.x) * 4; // Copy the pixels if (applyAlpha) @@ -279,7 +279,7 @@ const Uint8* Image::getPixelsPtr() const { if (!m_pixels.empty()) { - return &m_pixels[0]; + return m_pixels.data(); } else { diff --git a/src/SFML/Graphics/ImageLoader.cpp b/src/SFML/Graphics/ImageLoader.cpp index 8dc526b9..0e2edfac 100644 --- a/src/SFML/Graphics/ImageLoader.cpp +++ b/src/SFML/Graphics/ImageLoader.cpp @@ -118,7 +118,7 @@ bool ImageLoader::loadImageFromFile(const std::string& filename, std::vector& p { // Copy the loaded pixels to the pixel buffer pixels.resize(width * height * 4); - memcpy(&pixels[0], ptr, pixels.size()); + memcpy(pixels.data(), ptr, pixels.size()); } // Free the loaded pixels (they are now in our own pixel buffer) @@ -250,19 +250,19 @@ bool ImageLoader::saveImageToFile(const std::string& filename, const std::vector if (extension == "bmp") { // BMP format - if (stbi_write_bmp(filename.c_str(), size.x, size.y, 4, &pixels[0])) + if (stbi_write_bmp(filename.c_str(), size.x, size.y, 4, pixels.data())) return true; } else if (extension == "tga") { // TGA format - if (stbi_write_tga(filename.c_str(), size.x, size.y, 4, &pixels[0])) + if (stbi_write_tga(filename.c_str(), size.x, size.y, 4, pixels.data())) return true; } else if (extension == "png") { // PNG format - if (stbi_write_png(filename.c_str(), size.x, size.y, 4, &pixels[0], 0)) + if (stbi_write_png(filename.c_str(), size.x, size.y, 4, pixels.data(), 0)) return true; } else if (extension == "jpg" || extension == "jpeg") @@ -309,7 +309,7 @@ bool ImageLoader::writeJpg(const std::string& filename, const std::vector buffer[i * 3 + 1] = pixels[i * 4 + 1]; buffer[i * 3 + 2] = pixels[i * 4 + 2]; } - Uint8* ptr = &buffer[0]; + Uint8* ptr = buffer.data(); // Start compression jpeg_start_compress(&compressInfos, TRUE); diff --git a/src/SFML/Graphics/Shader.cpp b/src/SFML/Graphics/Shader.cpp index bae40eee..066a8b10 100644 --- a/src/SFML/Graphics/Shader.cpp +++ b/src/SFML/Graphics/Shader.cpp @@ -66,7 +66,7 @@ namespace { file.seekg(0, std::ios_base::beg); buffer.resize(static_cast(size)); - file.read(&buffer[0], size); + file.read(buffer.data(), size); } buffer.push_back('\0'); return true; @@ -86,7 +86,7 @@ namespace { buffer.resize(static_cast(size)); stream.seek(0); - sf::Int64 read = stream.read(&buffer[0], size); + sf::Int64 read = stream.read(buffer.data(), size); success = (read == size); } buffer.push_back('\0'); @@ -228,11 +228,11 @@ bool Shader::loadFromFile(const std::string& filename, Type type) // Compile the shader program if (type == Vertex) - return compile(&shader[0], NULL, NULL); + return compile(shader.data(), NULL, NULL); else if (type == Geometry) - return compile(NULL, &shader[0], NULL); + return compile(NULL, shader.data(), NULL); else - return compile(NULL, NULL, &shader[0]); + return compile(NULL, NULL, shader.data()); } @@ -256,7 +256,7 @@ bool Shader::loadFromFile(const std::string& vertexShaderFilename, const std::st } // Compile the shader program - return compile(&vertexShader[0], NULL, &fragmentShader[0]); + return compile(vertexShader.data(), NULL, fragmentShader.data()); } @@ -288,7 +288,7 @@ bool Shader::loadFromFile(const std::string& vertexShaderFilename, const std::st } // Compile the shader program - return compile(&vertexShader[0], &geometryShader[0], &fragmentShader[0]); + return compile(vertexShader.data(), geometryShader.data(), fragmentShader.data()); } @@ -334,11 +334,11 @@ bool Shader::loadFromStream(InputStream& stream, Type type) // Compile the shader program if (type == Vertex) - return compile(&shader[0], NULL, NULL); + return compile(shader.data(), NULL, NULL); else if (type == Geometry) - return compile(NULL, &shader[0], NULL); + return compile(NULL, shader.data(), NULL); else - return compile(NULL, NULL, &shader[0]); + return compile(NULL, NULL, shader.data()); } @@ -362,7 +362,7 @@ bool Shader::loadFromStream(InputStream& vertexShaderStream, InputStream& fragme } // Compile the shader program - return compile(&vertexShader[0], NULL, &fragmentShader[0]); + return compile(vertexShader.data(), NULL, fragmentShader.data()); } @@ -394,7 +394,7 @@ bool Shader::loadFromStream(InputStream& vertexShaderStream, InputStream& geomet } // Compile the shader program - return compile(&vertexShader[0], &geometryShader[0], &fragmentShader[0]); + return compile(vertexShader.data(), geometryShader.data(), fragmentShader.data()); } @@ -588,7 +588,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Vec2* vectorAr UniformBinder binder(*this, name); if (binder.location != -1) - glCheck(GLEXT_glUniform2fv(binder.location, length, &contiguous[0])); + glCheck(GLEXT_glUniform2fv(binder.location, length, contiguous.data())); } @@ -599,7 +599,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Vec3* vectorAr UniformBinder binder(*this, name); if (binder.location != -1) - glCheck(GLEXT_glUniform3fv(binder.location, length, &contiguous[0])); + glCheck(GLEXT_glUniform3fv(binder.location, length, contiguous.data())); } @@ -610,7 +610,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Vec4* vectorAr UniformBinder binder(*this, name); if (binder.location != -1) - glCheck(GLEXT_glUniform4fv(binder.location, length, &contiguous[0])); + glCheck(GLEXT_glUniform4fv(binder.location, length, contiguous.data())); } @@ -625,7 +625,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Mat3* matrixAr UniformBinder binder(*this, name); if (binder.location != -1) - glCheck(GLEXT_glUniformMatrix3fv(binder.location, length, GL_FALSE, &contiguous[0])); + glCheck(GLEXT_glUniformMatrix3fv(binder.location, length, GL_FALSE, contiguous.data())); } @@ -640,7 +640,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Mat4* matrixAr UniformBinder binder(*this, name); if (binder.location != -1) - glCheck(GLEXT_glUniformMatrix4fv(binder.location, length, GL_FALSE, &contiguous[0])); + glCheck(GLEXT_glUniformMatrix4fv(binder.location, length, GL_FALSE, contiguous.data())); } diff --git a/src/SFML/Graphics/Texture.cpp b/src/SFML/Graphics/Texture.cpp index 4c09dcf5..98d4fbb7 100644 --- a/src/SFML/Graphics/Texture.cpp +++ b/src/SFML/Graphics/Texture.cpp @@ -337,7 +337,7 @@ Image Texture::copyToImage() const glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, frameBuffer)); glCheck(GLEXT_glFramebufferTexture2D(GLEXT_GL_FRAMEBUFFER, GLEXT_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_texture, 0)); - glCheck(glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[0])); + glCheck(glReadPixels(0, 0, m_size.x, m_size.y, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data())); glCheck(GLEXT_glDeleteFramebuffers(1, &frameBuffer)); glCheck(GLEXT_glBindFramebuffer(GLEXT_GL_FRAMEBUFFER, previousFrameBuffer)); @@ -349,7 +349,7 @@ Image Texture::copyToImage() const { // Texture is not padded nor flipped, we can use a direct copy glCheck(glBindTexture(GL_TEXTURE_2D, m_texture)); - glCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels[0])); + glCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels.data())); } else { @@ -358,11 +358,11 @@ Image Texture::copyToImage() const // All the pixels will first be copied to a temporary array std::vector allPixels(m_actualSize.x * m_actualSize.y * 4); glCheck(glBindTexture(GL_TEXTURE_2D, m_texture)); - glCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &allPixels[0])); + glCheck(glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, allPixels.data())); // Then we copy the useful pixels from the temporary array to the final one - const Uint8* src = &allPixels[0]; - Uint8* dst = &pixels[0]; + const Uint8* src = allPixels.data(); + Uint8* dst = pixels.data(); int srcPitch = m_actualSize.x * 4; int dstPitch = m_size.x * 4; @@ -385,7 +385,7 @@ Image Texture::copyToImage() const // Create the image Image image; - image.create(m_size.x, m_size.y, &pixels[0]); + image.create(m_size.x, m_size.y, pixels.data()); return image; } diff --git a/src/SFML/Graphics/VertexArray.cpp b/src/SFML/Graphics/VertexArray.cpp index 0f9c8136..d64fa72a 100644 --- a/src/SFML/Graphics/VertexArray.cpp +++ b/src/SFML/Graphics/VertexArray.cpp @@ -144,7 +144,7 @@ FloatRect VertexArray::getBounds() const void VertexArray::draw(RenderTarget& target, RenderStates states) const { if (!m_vertices.empty()) - target.draw(&m_vertices[0], m_vertices.size(), m_primitiveType, states); + target.draw(m_vertices.data(), m_vertices.size(), m_primitiveType, states); } } // namespace sf diff --git a/src/SFML/Network/Packet.cpp b/src/SFML/Network/Packet.cpp index 8228af77..7dff0a8b 100644 --- a/src/SFML/Network/Packet.cpp +++ b/src/SFML/Network/Packet.cpp @@ -75,7 +75,7 @@ void Packet::clear() //////////////////////////////////////////////////////////// const void* Packet::getData() const { - return !m_data.empty() ? &m_data[0] : NULL; + return !m_data.empty() ? m_data.data() : NULL; } diff --git a/src/SFML/Network/TcpSocket.cpp b/src/SFML/Network/TcpSocket.cpp index be218cf3..73394011 100644 --- a/src/SFML/Network/TcpSocket.cpp +++ b/src/SFML/Network/TcpSocket.cpp @@ -317,13 +317,13 @@ Socket::Status TcpSocket::send(Packet& packet) std::vector blockToSend(sizeof(packetSize) + size); // Copy the packet size and data into the block to send - std::memcpy(&blockToSend[0], &packetSize, sizeof(packetSize)); + std::memcpy(blockToSend.data(), &packetSize, sizeof(packetSize)); if (size > 0) - std::memcpy(&blockToSend[0] + sizeof(packetSize), data, size); + std::memcpy(blockToSend.data() + sizeof(packetSize), data, size); // Send the data block std::size_t sent; - Status status = send(&blockToSend[0] + packet.m_sendPos, blockToSend.size() - packet.m_sendPos, sent); + Status status = send(blockToSend.data() + packet.m_sendPos, blockToSend.size() - packet.m_sendPos, sent); // In the case of a partial send, record the location to resume from if (status == Partial) @@ -385,14 +385,14 @@ Socket::Status TcpSocket::receive(Packet& packet) if (received > 0) { m_pendingPacket.Data.resize(m_pendingPacket.Data.size() + received); - char* begin = &m_pendingPacket.Data[0] + m_pendingPacket.Data.size() - received; + char* begin = m_pendingPacket.Data.data() + m_pendingPacket.Data.size() - received; std::memcpy(begin, buffer, received); } } // We have received all the packet data: we can copy it to the user packet if (!m_pendingPacket.Data.empty()) - packet.onReceive(&m_pendingPacket.Data[0], m_pendingPacket.Data.size()); + packet.onReceive(m_pendingPacket.Data.data(), m_pendingPacket.Data.size()); // Clear the pending packet data m_pendingPacket = PendingPacket(); diff --git a/src/SFML/Network/UdpSocket.cpp b/src/SFML/Network/UdpSocket.cpp index 81e2e49c..29ba0982 100644 --- a/src/SFML/Network/UdpSocket.cpp +++ b/src/SFML/Network/UdpSocket.cpp @@ -183,12 +183,12 @@ Socket::Status UdpSocket::receive(Packet& packet, IpAddress& remoteAddress, unsi // Receive the datagram std::size_t received = 0; - Status status = receive(&m_buffer[0], m_buffer.size(), received, remoteAddress, remotePort); + Status status = receive(m_buffer.data(), m_buffer.size(), received, remoteAddress, remotePort); // If we received valid data, we can copy it to the user packet packet.clear(); if ((status == Done) && (received > 0)) - packet.onReceive(&m_buffer[0], received); + packet.onReceive(m_buffer.data(), received); return status; } diff --git a/src/SFML/Window/FreeBSD/JoystickImpl.cpp b/src/SFML/Window/FreeBSD/JoystickImpl.cpp index 7636e472..8758b904 100644 --- a/src/SFML/Window/FreeBSD/JoystickImpl.cpp +++ b/src/SFML/Window/FreeBSD/JoystickImpl.cpp @@ -293,7 +293,7 @@ Joystick::Identification JoystickImpl::getIdentification() const //////////////////////////////////////////////////////////// JoystickState JoystickImpl::JoystickImpl::update() { - while (read(m_file, &m_buffer[0], m_length) == m_length) + while (read(m_file, m_buffer.data(), m_length) == m_length) { hid_data_t data = hid_start_parse(m_desc, 1 << hid_input, m_id); @@ -312,11 +312,11 @@ JoystickState JoystickImpl::JoystickImpl::update() if (usage == HUP_BUTTON) { - m_state.buttons[buttonIndex++] = hid_get_data(&m_buffer[0], &item); + m_state.buttons[buttonIndex++] = hid_get_data(m_buffer.data(), &item); } else if (usage == HUP_GENERIC_DESKTOP) { - int value = hid_get_data(&m_buffer[0], &item); + int value = hid_get_data(m_buffer.data(), &item); int axis = usageToAxis(usage); if (usage == HUG_HAT_SWITCH) diff --git a/src/SFML/Window/OSX/JoystickImpl.cpp b/src/SFML/Window/OSX/JoystickImpl.cpp index 215a6a92..117caa6f 100644 --- a/src/SFML/Window/OSX/JoystickImpl.cpp +++ b/src/SFML/Window/OSX/JoystickImpl.cpp @@ -45,8 +45,8 @@ namespace CFIndex length = CFStringGetLength(cfString); std::vector str(length); CFIndex maxSize = CFStringGetMaximumSizeForEncoding(length, kCFStringEncodingUTF8); - CFStringGetCString(cfString, &str[0], maxSize, kCFStringEncodingUTF8); - return &str[0]; + CFStringGetCString(cfString, str.data(), maxSize, kCFStringEncodingUTF8); + return str.data(); } // Get HID device property key as a string diff --git a/src/SFML/Window/OSX/SFContext.mm b/src/SFML/Window/OSX/SFContext.mm index 8c7e5a11..88d17551 100644 --- a/src/SFML/Window/OSX/SFContext.mm +++ b/src/SFML/Window/OSX/SFContext.mm @@ -258,7 +258,7 @@ void SFContext::createContext(SFContext* shared, m_settings.sRgbCapable = true; // Create the pixel format. - NSOpenGLPixelFormat* pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:&attrs[0]]; + NSOpenGLPixelFormat* pixFmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs.data()]; if (pixFmt == nil) { diff --git a/src/SFML/Window/Unix/GlxContext.cpp b/src/SFML/Window/Unix/GlxContext.cpp index 28d9f3de..a557ba1f 100644 --- a/src/SFML/Window/Unix/GlxContext.cpp +++ b/src/SFML/Window/Unix/GlxContext.cpp @@ -701,7 +701,7 @@ void GlxContext::createContext(GlxContext* shared) } // Create the context - m_context = glXCreateContextAttribsARB(m_display, *config, toShare, true, &attributes[0]); + m_context = glXCreateContextAttribsARB(m_display, *config, toShare, true, attributes.data()); if (!m_context) { diff --git a/src/SFML/Window/Unix/WindowImplX11.cpp b/src/SFML/Window/Unix/WindowImplX11.cpp index 64886443..af8ccbb5 100644 --- a/src/SFML/Window/Unix/WindowImplX11.cpp +++ b/src/SFML/Window/Unix/WindowImplX11.cpp @@ -109,7 +109,7 @@ namespace buffer[offset] = 0; // Remove the path to keep the executable name only - return basename(&buffer[0]); + return basename(buffer.data()); } // Default fallback name @@ -581,7 +581,7 @@ m_lastInputTime (0) std::string executableName = findExecutableName(); std::vector windowInstance(executableName.size() + 1, 0); std::copy(executableName.begin(), executableName.end(), windowInstance.begin()); - hint->res_name = &windowInstance[0]; + hint->res_name = windowInstance.data(); // The class name identifies a class of windows that // "are of the same type". We simply use the initial window name as @@ -589,7 +589,7 @@ m_lastInputTime (0) std::string ansiTitle = title.toAnsiString(); std::vector windowClass(ansiTitle.size() + 1, 0); std::copy(ansiTitle.begin(), ansiTitle.end(), windowClass.begin()); - hint->res_class = &windowClass[0]; + hint->res_class = windowClass.data(); XSetClassHint(m_display, m_window, hint); @@ -822,7 +822,7 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8 } } } - m_iconMaskPixmap = XCreatePixmapFromBitmapData(m_display, m_window, (char*)&maskPixels[0], width, height, 1, 0, 1); + m_iconMaskPixmap = XCreatePixmapFromBitmapData(m_display, m_window, reinterpret_cast(maskPixels.data()), width, height, 1, 0, 1); // Send our new icon to the window through the WMHints XWMHints* hints = XAllocWMHints(); @@ -835,7 +835,7 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8 // ICCCM wants BGRA pixels: swap red and blue channels // ICCCM also wants the first 2 unsigned 32-bit values to be width and height std::vector icccmIconPixels(2 + width * height, 0); - unsigned long* ptr = &icccmIconPixels[0]; + unsigned long* ptr = icccmIconPixels.data(); *ptr++ = width; *ptr++ = height; @@ -856,7 +856,7 @@ void WindowImplX11::setIcon(unsigned int width, unsigned int height, const Uint8 XA_CARDINAL, 32, PropModeReplace, - reinterpret_cast(&icccmIconPixels[0]), + reinterpret_cast(icccmIconPixels.data()), 2 + width * height); XFlush(m_display); @@ -1249,7 +1249,7 @@ void WindowImplX11::setProtocols() XA_ATOM, 32, PropModeReplace, - reinterpret_cast(&atoms[0]), + reinterpret_cast(atoms.data()), atoms.size()); } else diff --git a/src/SFML/Window/Win32/WglContext.cpp b/src/SFML/Window/Win32/WglContext.cpp index 6037b0dc..198f7ef2 100644 --- a/src/SFML/Window/Win32/WglContext.cpp +++ b/src/SFML/Window/Win32/WglContext.cpp @@ -649,7 +649,7 @@ void WglContext::createContext(WglContext* shared) } // Create the context - m_context = wglCreateContextAttribsARB(m_deviceContext, sharedContext, &attributes[0]); + m_context = wglCreateContextAttribsARB(m_deviceContext, sharedContext, attributes.data()); } else { diff --git a/src/SFML/Window/Win32/WindowImplWin32.cpp b/src/SFML/Window/Win32/WindowImplWin32.cpp index f21a85b3..9c55180d 100644 --- a/src/SFML/Window/Win32/WindowImplWin32.cpp +++ b/src/SFML/Window/Win32/WindowImplWin32.cpp @@ -364,7 +364,7 @@ void WindowImplWin32::setIcon(unsigned int width, unsigned int height, const Uin } // Create the icon from the pixel array - m_icon = CreateIcon(GetModuleHandleW(NULL), width, height, 1, 32, NULL, &iconPixels[0]); + m_icon = CreateIcon(GetModuleHandleW(NULL), width, height, 1, 32, NULL, iconPixels.data()); // Set it as both big and small icon of the window if (m_icon)