Boost logo

Boost :

Subject: Re: [boost] boost::noncopyable errors are difficult to diagnose on MSVC
From: Zachary Turner (divisortheory_at_[hidden])
Date: 2009-11-06 23:26:52


On Fri, Nov 6, 2009 at 9:25 PM, Gottlob Frege <gottlobfrege_at_[hidden]>wrote:

> On Fri, Nov 6, 2009 at 5:13 PM, Beman Dawes <bdawes_at_[hidden]> wrote:
> > On Fri, Nov 6, 2009 at 1:17 PM, Emil Dotchevski
> > <emildotchevski_at_[hidden]> wrote:
> >> On Fri, Nov 6, 2009 at 9:44 AM, Zachary Turner <divisortheory_at_[hidden]>
> wrote:
> >>> Is there anything that can be done to improve the error messages
> generated
> >>> by the compiler when a copy fails to be made due to a
> boost::noncopyable?
> >>
> >> Easy cure is to spell out the private declarations for the copy
> >> constructor and the assignment operator "by hand". We all know that
> >> this spells "non-copyable".
> >
> > Because of C++0x deleted functions, the idiom for noncopyable is going
> > to change.
> [...]
>
> Interesting stuff, however...
> I'm not sure if any of that will help the errors. I haven't tried any
> experiments, but It looks to me that even if the compiler tells you
> exactly what class is not copyable, it doesn't tell you where the
> attempted copy is taking place.
>
> And I'm not sure if anything but a compiler fix will make it better.
>

Indeed, and this is the real problem and the reason I mentioned it would
probably involve catering to the compiler and be highly compiler specific,
albeit extremely useful. There are always ways to finesse error messages or
do tricky things just to get the compiler to report a different error
message. In this case the goal would be to make the compiler fail in such a
way as to report the class the actual copy was taking place in. I'm also
not sure if it's possible, but if it were it would be pretty useful.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk