diff --git a/src/Magnum/Image.h b/src/Magnum/Image.h index 66ff73f1f..55655962b 100644 --- a/src/Magnum/Image.h +++ b/src/Magnum/Image.h @@ -107,17 +107,9 @@ template class Image { Image& operator=(Image&& other) noexcept; /** @brief Conversion to view */ - /*implicit*/ operator ImageView() - #ifndef CORRADE_GCC47_COMPATIBILITY - const &; - #else - const; - #endif - - #ifndef CORRADE_GCC47_COMPATIBILITY - /** @overload */ - /*implicit*/ operator ImageView() const && = delete; - #endif + /* Not restricted to const&, because we might want to pass the view to + another function in an oneliner (e.g. saving screenshot) */ + /*implicit*/ operator ImageView() const; /** @brief Storage of pixel data */ PixelStorage storage() const { return _storage; } @@ -304,17 +296,7 @@ template class CompressedImage { CompressedImage& operator=(CompressedImage&& other) noexcept; /** @brief Conversion to view */ - /*implicit*/ operator CompressedImageView() - #ifndef CORRADE_GCC47_COMPATIBILITY - const &; - #else - const; - #endif - - #ifndef CORRADE_GCC47_COMPATIBILITY - /** @overload */ - /*implicit*/ operator CompressedImageView() const && = delete; - #endif + /*implicit*/ operator CompressedImageView() const; #ifndef MAGNUM_TARGET_GLES /** @@ -458,22 +440,12 @@ template inline CompressedImage& CompressedI return *this; } -template inline Image::operator ImageView() -#ifndef CORRADE_GCC47_COMPATIBILITY -const & -#else -const -#endif +template inline Image::operator ImageView() const { return ImageView{_storage, _format, _type, _size, _data}; } -template inline CompressedImage::operator CompressedImageView() -#ifndef CORRADE_GCC47_COMPATIBILITY -const & -#else -const -#endif +template inline CompressedImage::operator CompressedImageView() const { return CompressedImageView{ #ifndef MAGNUM_TARGET_GLES diff --git a/src/Magnum/Test/ImageTest.cpp b/src/Magnum/Test/ImageTest.cpp index b85f10d41..f6f85cc4b 100644 --- a/src/Magnum/Test/ImageTest.cpp +++ b/src/Magnum/Test/ImageTest.cpp @@ -213,18 +213,6 @@ void ImageTest::toView() { CORRADE_COMPARE(b.type(), PixelType::UnsignedByte); CORRADE_COMPARE(b.size(), Vector2i(1, 3)); CORRADE_COMPARE(b.data(), data); - - CORRADE_VERIFY((std::is_convertible::value)); - { - #ifdef CORRADE_GCC47_COMPATIBILITY - CORRADE_EXPECT_FAIL("Rvalue references for *this are not supported in GCC < 4.8.1."); - #endif - #ifdef CORRADE_MSVC2015_COMPATIBILITY - CORRADE_EXPECT_FAIL("std::is_convertible is still buggy in MSVC 2015."); - #endif - CORRADE_VERIFY(!(std::is_convertible::value)); - CORRADE_VERIFY(!(std::is_convertible::value)); - } } void ImageTest::toViewCompressed() { @@ -243,18 +231,6 @@ void ImageTest::toViewCompressed() { CORRADE_COMPARE(b.size(), Vector2i(4, 4)); CORRADE_COMPARE(b.data(), data); CORRADE_COMPARE(b.data().size(), 8); - - CORRADE_VERIFY((std::is_convertible::value)); - { - #ifdef CORRADE_GCC47_COMPATIBILITY - CORRADE_EXPECT_FAIL("Rvalue references for *this are not supported in GCC < 4.8.1."); - #endif - #ifdef CORRADE_MSVC2015_COMPATIBILITY - CORRADE_EXPECT_FAIL("std::is_convertible is still buggy in MSVC 2015."); - #endif - CORRADE_VERIFY(!(std::is_convertible::value)); - CORRADE_VERIFY(!(std::is_convertible::value)); - } } void ImageTest::release() { diff --git a/src/Magnum/Trade/ImageData.cpp b/src/Magnum/Trade/ImageData.cpp index 39afabd0b..179ae5b52 100644 --- a/src/Magnum/Trade/ImageData.cpp +++ b/src/Magnum/Trade/ImageData.cpp @@ -68,23 +68,13 @@ template std::tuple(*this); } -template ImageData::operator ImageView() -#ifndef CORRADE_GCC47_COMPATIBILITY -const & -#else -const -#endif +template ImageData::operator ImageView() const { CORRADE_ASSERT(!_compressed, "Trade::ImageData::type(): the image is compressed", (ImageView{_storage, _format, _type, _size})); return ImageView{_storage, _format, _type, _size, _data}; } -template ImageData::operator CompressedImageView() -#ifndef CORRADE_GCC47_COMPATIBILITY -const & -#else -const -#endif +template ImageData::operator CompressedImageView() const { #ifndef MAGNUM_TARGET_GLES CORRADE_ASSERT(_compressed, "Trade::ImageData::type(): the image is not compressed", (CompressedImageView{_compressedStorage, _compressedFormat, _size})); diff --git a/src/Magnum/Trade/ImageData.h b/src/Magnum/Trade/ImageData.h index 169d2adda..77aaf941b 100644 --- a/src/Magnum/Trade/ImageData.h +++ b/src/Magnum/Trade/ImageData.h @@ -130,17 +130,9 @@ template class ImageData { * The image is expected to be uncompressed. * @see @ref isCompressed() */ - /*implicit*/ operator ImageView() - #ifndef CORRADE_GCC47_COMPATIBILITY - const &; - #else - const; - #endif - - #ifndef CORRADE_GCC47_COMPATIBILITY - /** @overload */ - /*implicit*/ operator ImageView() const && = delete; - #endif + /* Not restricted to const&, because we might want to pass the view to + another function in an oneliner (e.g. saving screenshot) */ + /*implicit*/ operator ImageView() const; /** * @brief Conversion to compressed view @@ -148,17 +140,9 @@ template class ImageData { * The image is expected to be compressed. * @see @ref isCompressed() */ - /*implicit*/ operator CompressedImageView() - #ifndef CORRADE_GCC47_COMPATIBILITY - const &; - #else - const; - #endif - - #ifndef CORRADE_GCC47_COMPATIBILITY - /** @overload */ - /*implicit*/ operator CompressedImageView() const && = delete; - #endif + /* Not restricted to const&, because we might want to pass the view to + another function in an oneliner (e.g. saving screenshot) */ + /*implicit*/ operator CompressedImageView() const; /** * @brief Storage of pixel data diff --git a/src/Magnum/Trade/Test/ImageDataTest.cpp b/src/Magnum/Trade/Test/ImageDataTest.cpp index 07720ce91..d27e424fa 100644 --- a/src/Magnum/Trade/Test/ImageDataTest.cpp +++ b/src/Magnum/Trade/Test/ImageDataTest.cpp @@ -174,18 +174,6 @@ void ImageDataTest::toView() { CORRADE_COMPARE(b.type(), PixelType::UnsignedByte); CORRADE_COMPARE(b.size(), Vector2i(4, 1)); CORRADE_COMPARE(b.data(), data); - - CORRADE_VERIFY((std::is_convertible::value)); - { - #ifdef CORRADE_GCC47_COMPATIBILITY - CORRADE_EXPECT_FAIL("Rvalue references for *this are not supported in GCC < 4.8.1."); - #endif - #ifdef CORRADE_MSVC2015_COMPATIBILITY - CORRADE_EXPECT_FAIL("std::is_convertible is still buggy in MSVC 2015."); - #endif - CORRADE_VERIFY(!(std::is_convertible::value)); - CORRADE_VERIFY(!(std::is_convertible::value)); - } } void ImageDataTest::toViewCompressed() { @@ -197,18 +185,6 @@ void ImageDataTest::toViewCompressed() { CORRADE_COMPARE(b.size(), Vector2i(4, 4)); CORRADE_COMPARE(b.data(), data); CORRADE_COMPARE(b.data().size(), 8); - - CORRADE_VERIFY((std::is_convertible::value)); - { - #ifdef CORRADE_GCC47_COMPATIBILITY - CORRADE_EXPECT_FAIL("Rvalue references for *this are not supported in GCC < 4.8.1."); - #endif - #ifdef CORRADE_MSVC2015_COMPATIBILITY - CORRADE_EXPECT_FAIL("std::is_convertible is still buggy in MSVC 2015."); - #endif - CORRADE_VERIFY(!(std::is_convertible::value)); - CORRADE_VERIFY(!(std::is_convertible::value)); - } } void ImageDataTest::release() {