diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2015-06-15 09:17:40 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2015-06-15 09:53:51 +0200 |
commit | 0f1976988a69fd91100a73331d12f21aa9861e83 (patch) | |
tree | fd877e622403bf50ed38cdbe9f6c5c4889731add | |
parent | 4331aa3cbab9ea7505e1d31ac674ee8ca5d9c314 (diff) |
Fix VclPtr assignment operators
The original templated assignment operator would never have been used, as
std::enable_if expects a bool value as first template argument. But it was also
unnecessary anyway:
(1) Assignment from VclPtr<reference_type> was (and is) covered by the
implicitly defined copy assignment operator.
(2) Assignment from naked reference_type* was covered by the user-supplied
constructor from reference_type* to temporary, followed by (1); it is now
covered directly by the user-supplied assignment operator from
reference_type*.
(3) Assignment from VclPtr<derived_type> was covered by the user-supplied,
templated constructor from VclPtr<derived_type> to temporary, followed by
(1); it is now covered directly by the user-supplied, templated assignment
operator from VclPtr<derived_type>.
(4) Assignment from naked derived_type* was (and is) covered by an implicit
pointer up-cast, followed by (2).
Change-Id: I3c7527feea72fdda76d911a42ae856c353b700b5
-rw-r--r-- | include/vcl/vclptr.hxx | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/include/vcl/vclptr.hxx b/include/vcl/vclptr.hxx index cd8f46f5dc54..79c784f23625 100644 --- a/include/vcl/vclptr.hxx +++ b/include/vcl/vclptr.hxx @@ -65,7 +65,8 @@ private: }; public: - typedef typename C< sizeof (f(H(), 0)) == 1, void *, void >::t t; + static bool const value = sizeof (f(H(), 0)) == 1; + typedef typename C< value, void *, void >::t t; }; }; }; // namespace detail, namespace vcl @@ -163,16 +164,23 @@ public: m_rInnerRef.set(pBody); } - /** Up-casting conversion constructor: Copies interface reference. + /** Up-casting assignment operator. - Does not work for up-casts to ambiguous bases. For the special case of - up-casting to Reference< XInterface >, see the corresponding conversion - operator. + Does not work for up-casts to ambiguous bases. @param rRef another reference */ - template< class derived_type, class = typename std::enable_if< ::vcl::detail::UpCast< reference_type, derived_type >::t >::type > - inline VclPtr<reference_type>& operator= (derived_type * pBody) + template<typename derived_type> + typename std::enable_if< + vcl::detail::UpCast<reference_type, derived_type>::value, + VclPtr &>::type + operator =(VclPtr<derived_type> const & rRef) + { + m_rInnerRef.set(rRef.get()); + return *this; + } + + VclPtr & operator =(reference_type * pBody) { m_rInnerRef.set(pBody); return *this; |