From: bungeman Date: Mon, 25 Jan 2016 21:00:33 +0000 (-0800) Subject: Work around vs2013sp2-3 bug in skstd::unique_ptr. X-Git-Tag: submit/tizen/20180928.044319~129^2~2395 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1fce5584cfd7c9cc36388b9d250f03d56ee9b254;p=platform%2Fupstream%2FlibSkiaSharp.git Work around vs2013sp2-3 bug in skstd::unique_ptr. When compiling skstd::unique_ptr::compressed_base with the vc++ in some intermediate service pack versions of Visual Studio 2013 the compiler will crash with an internal compiler error. In the interest of reducing headaches, work around this issue in skstd::unique_ptr until std::unique_ptr can be used. BUG=skia:4564 Review URL: https://codereview.chromium.org/1636503002 --- diff --git a/include/private/SkUniquePtr.h b/include/private/SkUniquePtr.h index d87ce29480..b1097d51eb 100644 --- a/include/private/SkUniquePtr.h +++ b/include/private/SkUniquePtr.h @@ -48,7 +48,7 @@ public: using deleter_type = D; private: - template ::value /*&& !is_final::value*/> + template struct compressed_base : private B { /*constexpr*/ compressed_base() : B() {} /*constexpr*/ compressed_base(const B& b) : B(b) {} @@ -68,25 +68,29 @@ private: void swap(compressed_base& that) /*noexcept*/ { SkTSwap(fb, that.fB); } }; - struct compressed_data : private compressed_base { + // C++14 adds '&& !std::is_final::value' to the bool condition. + // compressed_base_t exists and has this form to work around a bug in vs2013sp2-3 + using compressed_base_t = compressed_base::value>; + + struct compressed_data : private compressed_base_t { pointer fPtr; - /*constexpr*/ compressed_data() : compressed_base(), fPtr() {} + /*constexpr*/ compressed_data() : compressed_base_t(), fPtr() {} /*constexpr*/ compressed_data(const pointer& ptr, const deleter_type& d) - : compressed_base(d), fPtr(ptr) {} + : compressed_base_t(d), fPtr(ptr) {} template ::value && is_convertible::value >> /*constexpr*/ compressed_data(U1&& ptr, U2&& d) - : compressed_base(std::forward(d)), fPtr(std::forward(ptr)) {} + : compressed_base_t(std::forward(d)), fPtr(std::forward(ptr)) {} /*constexpr*/ pointer& getPointer() /*noexcept*/ { return fPtr; } /*constexpr*/ pointer const& getPointer() const /*noexcept*/ { return fPtr; } /*constexpr*/ deleter_type& getDeleter() /*noexcept*/ { - return compressed_base::get(); + return compressed_base_t::get(); } /*constexpr*/ deleter_type const& getDeleter() const /*noexcept*/ { - return compressed_base::get(); + return compressed_base_t::get(); } void swap(compressed_data& that) /*noexcept*/ { - compressed_base::swap(static_cast>(that)); + compressed_base_t::swap(static_cast(that)); SkTSwap(fPtr, that.fPtr); } }; @@ -221,8 +225,7 @@ public: using deleter_type = D; private: - template ::value /*&& !is_final::value*/> - struct compressed_base : private B { + template struct compressed_base : private B { /*constexpr*/ compressed_base() : B() {} /*constexpr*/ compressed_base(const B& b) : B(b) {} /*constexpr*/ compressed_base(B&& b) : B(std::move(b)) {} @@ -241,25 +244,29 @@ private: void swap(compressed_base& that) /*noexcept*/ { SkTSwap(fb, that.fB); } }; - struct compressed_data : private compressed_base { + // C++14 adds '&& !std::is_final::value' to the bool condition. + // compressed_base_t exists and has this form to work around a bug in vs2013sp2-3 + using compressed_base_t = compressed_base::value>; + + struct compressed_data : private compressed_base_t { pointer fPtr; - /*constexpr*/ compressed_data() : compressed_base(), fPtr() {} + /*constexpr*/ compressed_data() : compressed_base_t(), fPtr() {} /*constexpr*/ compressed_data(const pointer& ptr, const deleter_type& d) - : compressed_base(d), fPtr(ptr) {} + : compressed_base_t(d), fPtr(ptr) {} template ::value && is_convertible::value >> /*constexpr*/ compressed_data(U1&& ptr, U2&& d) - : compressed_base(std::forward(d)), fPtr(std::forward(ptr)) {} + : compressed_base_t(std::forward(d)), fPtr(std::forward(ptr)) {} /*constexpr*/ pointer& getPointer() /*noexcept*/ { return fPtr; } /*constexpr*/ pointer const& getPointer() const /*noexcept*/ { return fPtr; } /*constexpr*/ deleter_type& getDeleter() /*noexcept*/ { - return compressed_base::get(); + return compressed_base_t::get(); } /*constexpr*/ deleter_type const& getDeleter() const /*noexcept*/ { - return compressed_base::get(); + return compressed_base_t::get(); } void swap(compressed_data& that) /*noexcept*/ { - compressed_base::swap(static_cast>(that)); + compressed_base_t::swap(static_cast(that)); SkTSwap(fPtr, that.fPtr); } };