| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkUniquePtr_DEFINED | 8 #ifndef SkUniquePtr_DEFINED |
| 9 #define SkUniquePtr_DEFINED | 9 #define SkUniquePtr_DEFINED |
| 10 | 10 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 template <typename U> static T* detector(...); | 41 template <typename U> static T* detector(...); |
| 42 using type = decltype(detector<remove_reference_t<D>>(0)); | 42 using type = decltype(detector<remove_reference_t<D>>(0)); |
| 43 }; | 43 }; |
| 44 | 44 |
| 45 public: | 45 public: |
| 46 using pointer = typename pointer_type_detector::type; | 46 using pointer = typename pointer_type_detector::type; |
| 47 using element_type = T; | 47 using element_type = T; |
| 48 using deleter_type = D; | 48 using deleter_type = D; |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 template <typename B, bool = is_empty<B>::value /*&& !is_final<B>::value*/> | 51 template <typename B, bool = std::is_empty<B>::value /*&& !is_final<B>::valu
e*/> |
| 52 struct compressed_base : private B { | 52 struct compressed_base : private B { |
| 53 /*constexpr*/ compressed_base() : B() {} | 53 /*constexpr*/ compressed_base() : B() {} |
| 54 /*constexpr*/ compressed_base(const B& b) : B(b) {} | 54 /*constexpr*/ compressed_base(const B& b) : B(b) {} |
| 55 /*constexpr*/ compressed_base(B&& b) : B(std::move(b)) {} | 55 /*constexpr*/ compressed_base(B&& b) : B(std::move(b)) {} |
| 56 /*constexpr*/ B& get() /*noexcept*/ { return *this; } | 56 /*constexpr*/ B& get() /*noexcept*/ { return *this; } |
| 57 /*constexpr*/ B const& get() const /*noexcept*/ { return *this; } | 57 /*constexpr*/ B const& get() const /*noexcept*/ { return *this; } |
| 58 void swap(compressed_base&) /*noexcept*/ { } | 58 void swap(compressed_base&) /*noexcept*/ { } |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 template <typename B> struct compressed_base<B, false> { | 61 template <typename B> struct compressed_base<B, false> { |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 214 template <typename U> static T* detector(...); | 214 template <typename U> static T* detector(...); |
| 215 using type = decltype(detector<remove_reference_t<D>>(0)); | 215 using type = decltype(detector<remove_reference_t<D>>(0)); |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 public: | 218 public: |
| 219 using pointer = typename pointer_type_detector::type; | 219 using pointer = typename pointer_type_detector::type; |
| 220 using element_type = T; | 220 using element_type = T; |
| 221 using deleter_type = D; | 221 using deleter_type = D; |
| 222 | 222 |
| 223 private: | 223 private: |
| 224 template <typename B, bool = is_empty<B>::value /*&& !is_final<B>::value*/> | 224 template <typename B, bool = std::is_empty<B>::value /*&& !is_final<B>::valu
e*/> |
| 225 struct compressed_base : private B { | 225 struct compressed_base : private B { |
| 226 /*constexpr*/ compressed_base() : B() {} | 226 /*constexpr*/ compressed_base() : B() {} |
| 227 /*constexpr*/ compressed_base(const B& b) : B(b) {} | 227 /*constexpr*/ compressed_base(const B& b) : B(b) {} |
| 228 /*constexpr*/ compressed_base(B&& b) : B(std::move(b)) {} | 228 /*constexpr*/ compressed_base(B&& b) : B(std::move(b)) {} |
| 229 /*constexpr*/ B& get() /*noexcept*/ { return *this; } | 229 /*constexpr*/ B& get() /*noexcept*/ { return *this; } |
| 230 /*constexpr*/ B const& get() const /*noexcept*/ { return *this; } | 230 /*constexpr*/ B const& get() const /*noexcept*/ { return *this; } |
| 231 void swap(compressed_base&) /*noexcept*/ { } | 231 void swap(compressed_base&) /*noexcept*/ { } |
| 232 }; | 232 }; |
| 233 | 233 |
| 234 template <typename B> struct compressed_base<B, false> { | 234 template <typename B> struct compressed_base<B, false> { |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 | 392 |
| 393 template <typename T, typename D> | 393 template <typename T, typename D> |
| 394 inline bool operator!=(std::nullptr_t, const unique_ptr<T, D>& b) /*noexcept*/ { | 394 inline bool operator!=(std::nullptr_t, const unique_ptr<T, D>& b) /*noexcept*/ { |
| 395 //return (bool)b; | 395 //return (bool)b; |
| 396 return b.is_attached(); | 396 return b.is_attached(); |
| 397 } | 397 } |
| 398 | 398 |
| 399 } // namespace skstd | 399 } // namespace skstd |
| 400 | 400 |
| 401 #endif | 401 #endif |
| OLD | NEW |