List:MySQL++« Previous MessageNext Message »
From:Jonathan Wakely Date:April 20 2007 4:15pm
Subject:Re: Differences between query constructors
View as plain text  
On 20/04/07, Warren Young <mysqlpp@stripped> wrote:
> But seriously, I really don't think we want to do that.  Query isn't
> simple enough that I trust a C++ bitwise copy to do the right thing.
> You need a real copy ctor to avoid disaster.

(N.B. An implicitly-defined copy ctor isn't a bitwise copy except for POD types)

> I'd argue that Queries shouldn't be copied at all, but the response to
> that is to make the copy ctor private, not get rid of it entirely.

Actually, if you remove your user-defined copy ctor then the implicit
one will try to copy the std::ostream base and the std::stringbuf
member, both of which are non-copyable. So in this case simply
removing it would be even better than doing the private-and-undefined
trick, since you'd be guaranteed a compile-time failure if you try to
copy a Query.

With the private-and-undefined trick the Query class itself and its
friend SQLQueryParams could accidentally create copies, which wouldn't
be caught until link time.

Jon
Thread
Differences between query constructorsJoel Fielder20 Apr
  • Re: Differences between query constructorsWarren Young20 Apr
    • Re: Differences between query constructorsJoel Fielder20 Apr
      • Re: Differences between query constructorsWarren Young20 Apr
        • Re: Differences between query constructorsJonathan Wakely20 Apr