Boost logo

Boost :

Subject: Re: [boost] [xint] Boost.XInt formal review
From: Christopher Jefferson (chris_at_[hidden])
Date: 2011-03-08 04:54:45


On 8 Mar 2011, at 09:36, Sebastian Redl wrote:

> On 07.03.2011 20:27, SATAN66613 wrote:
>> on 07.03.2011 at 13:48
>> Christopher Jefferson wrote :
>>> So users of a expression-template based xint would need to know about proto::deep_copy?
>>> Also, I would expect these problems to become more serious in C++0x
>>> code, because users will probably write expressions like:
>>> auto i = x + y;
>>> Which would be fine for built-in types, and introduce bugs if x or
>>> y was an xint::integer, using proto.
>> could we prevent this misusage by making copy constructor of the
>> expression class private (possibly never implementing it)?
> Since we're talking C++0x, making it =delete would be the right thing.
> And yes, that should prevent the misuse. Come to think of it, I can't think of any reason why that wouldn't work.

That was my first thought. I'm not particularly knowledgable about boost::proto, so I don't know how much disabling the copy constructor would limit the functionality. If it didn't create too many problems it is probably the way to go, possibly with a 'clone' function if that would be useful for people really want to make a copy, and know what they are doing.

Chris


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