Kaydet (Commit) 5fba3a9a authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Prevent perfect forwarding ctor from hijacking copy construction attempts

...and hope that this will already be enough to help MSVC 2015 re.
<http://paste.openstack.org/show/444734/>.

"This leads to beavior that's intuitive only if you've spent so much time around
compilers and compiler-writers, you've forgotten what it's like to be human," as
Meyers so aptly put it.

Change-Id: I4015bf831cd4cfed6988cc3517f719b756e27bb8
üst d3c93279
...@@ -371,6 +371,21 @@ public: ...@@ -371,6 +371,21 @@ public:
: ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE ) : ScopedVclPtr<reference_type>( new reference_type(std::forward<Arg>(arg)...), SAL_NO_ACQUIRE )
{ {
} }
private:
// Prevent the above perfect forwarding ctor from hijacking (accidental)
// attempts at ScopedVclPtrInstance copy construction (where the hijacking
// would typically lead to somewhat obscure error messages); both non-const
// and const variants are needed here, as the ScopedVclPtr base class has a
// const--variant copy ctor, so the implicitly declared copy ctor for
// ScopedVclPtrInstance would also be the const variant, so non-const copy
// construction attempts would be hijacked by the perfect forwarding ctor;
// but if we only declared a non-const variant here, the const variant would
// no longer be implicitly declared (as there would already be an explicitly
// declared copy ctor), so const copy construction attempts would then be
// hijacked by the perfect forwarding ctor:
ScopedVclPtrInstance(ScopedVclPtrInstance &) = delete;
ScopedVclPtrInstance(ScopedVclPtrInstance const &) = delete;
}; };
#endif // INCLUDED_VCL_PTR_HXX #endif // INCLUDED_VCL_PTR_HXX
......
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