[Bug libstdc++/43183] std::unique_ptr::reset() does not conform to N3035.

tjgolubi at netins dot net gcc-bugzilla@gcc.gnu.org
Mon Mar 1 23:23:00 GMT 2010



------- Comment #13 from tjgolubi at netins dot net  2010-03-01 23:23 -------
Subject: Re:  std::unique_ptr::reset() does not conform to N3035.

I think you are correct now.  Thank you for the explanation.

terry

----- Original Message ----- 
From: "redi at gcc dot gnu dot org" <gcc-bugzilla@gcc.gnu.org>
To: <tjgolubi@netins.net>
Sent: Monday, March 01, 2010 4:38 PM
Subject: [Bug libstdc++/43183] std::unique_ptr::reset() does not conform to 
N3035.


>
>
> ------- 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
>
> ------- You are receiving this mail because: -------
> You reported the bug, or are watching the reporter. 


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43183



More information about the Gcc-bugs mailing list