This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/43183] std::unique_ptr::reset() does not conform to N3035.
- From: "redi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 1 Mar 2010 22:38:24 -0000
- Subject: [Bug libstdc++/43183] std::unique_ptr::reset() does not conform to N3035.
- References: <bug-43183-18834@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #12 from redi at gcc dot gnu dot org 2010-03-01 22:38 -------
Bear in mind that a custom deleter with custom pointer type might have very
different semantics for comparing pointer values and for invoking the deleter.
Consider a custom D::pointer which keeps a generation count, which is not used
when comparing for equality:
template<class T>
struct MyDeleter {
struct pointer {
int generation;
T* ptr;
pointer() : generation(), ptr() { }
bool operator==(pointer rhs)
{ return ptr == rhs.ptr; }
};
void operator()(pointer p) const
{
do_something(ptr.generation);
delete p.ptr;
}
void do_something(int gen);
};
Your suggested implementation would not update the value, because the equality
test is true, but that would be wrong i.e. you would have failed to reset the
unique_ptr as requested by the user.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43183