Kaydet (Commit) 0f197698 authored tarafından Stephan Bergmann's avatar Stephan Bergmann

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
üst 4331aa3c
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment