From ae4c8f55b628c629d89dd67c1be6799fb85cf509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Fri, 7 Oct 2016 20:15:55 +0200 Subject: [PATCH] Avoid unwanted decay to deprecated functions in Image constructors. Only possible to hit this in tests, otherwise I don't see much point in creating a 0x0 image. --- src/Magnum/Image.h | 5 +++++ src/Magnum/Trade/ImageData.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/src/Magnum/Image.h b/src/Magnum/Image.h index 4bbbfdbe0..a725c83ed 100644 --- a/src/Magnum/Image.h +++ b/src/Magnum/Image.h @@ -72,6 +72,11 @@ template class Image { * instead. */ explicit CORRADE_DEPRECATED("use Image(PixelFormat, PixelType, const VectorTypeFor&, Containers::Array&&) instead") Image(PixelFormat format, PixelType type, const VectorTypeFor& size, void* data) noexcept: Image{{}, format, type, size, Containers::Array{reinterpret_cast(data), Implementation::imageDataSizeFor(format, type, size)}} {} + #ifndef DOXYGEN_GENERATING_OUTPUT + /* To avoid decay of nullptr to const void* and unwanted use of + deprecated function */ + explicit Image(PixelFormat format, PixelType type, const VectorTypeFor& size, std::nullptr_t) noexcept: Image{{}, format, type, size, nullptr} {} + #endif #endif /** diff --git a/src/Magnum/Trade/ImageData.h b/src/Magnum/Trade/ImageData.h index fc38a63bc..33b1d3dd7 100644 --- a/src/Magnum/Trade/ImageData.h +++ b/src/Magnum/Trade/ImageData.h @@ -80,6 +80,11 @@ template class ImageData { * @deprecated Use @ref ImageData(PixelFormat, PixelType, const VectorTypeFor&, Containers::Array&&, const void*) instead. */ explicit CORRADE_DEPRECATED("use ImageData(PixelFormat, PixelType, const VectorTypeFor&, Containers::Array&&) instead") ImageData(PixelFormat format, PixelType type, const VectorTypeFor& size, void* data) noexcept: ImageData{format, type, size, Containers::Array{reinterpret_cast(data), Magnum::Implementation::imageDataSizeFor(format, type, size)}} {} + #ifndef DOXYGEN_GENERATING_OUTPUT + /* To avoid decay of nullptr to const void* and unwanted use of + deprecated function */ + explicit ImageData(PixelFormat format, PixelType type, const VectorTypeFor& size, std::nullptr_t) noexcept: ImageData{{}, format, type, size, nullptr} {} + #endif #endif #ifndef MAGNUM_TARGET_GLES