Boost logo

Boost :

From: Beman Dawes (beman_at_[hidden])
Date: 2000-03-13 16:50:26


At 02:08 PM 3/13/00 +0000, jorg.schaible_at_[hidden] wrote:

>if the new/delete is separated from shared_ptr/scoped_ptr you are
also
>able to write allocators using an incomplete type support and the
opaque
>versions are obsolete.

You mean by including either the copy_ptr_t.hh or copy_ptr.hh
headers?

But doesn't that prevent you from using a CopyPtr in both the
incomplete and complete forms in the same translation unit?

For example, say a header, my.hpp contains:

#include <copy_ptr.hh>
class My {
  class my_imp;
  CopyPtr<my_imp> imp;
  My();
};
  
This is used in a program:

#include <my.hpp>
void f() {
  My x;
  My y(x);
  ...
}

Then you decide to use CopyPtr on a complete type within f(), so you
change it to this:

#include <my.hpp>
#include <copy_ptr-t.hh>
void f() {
  My x;
  My y(x);
  CopyPtr<int> z;
}

Then you are in trouble; the compiler will try to instantiate my_imp
on an incomplete type, and report an error.

(A quick test with CodeWarrior did indeed report that error.)

Or am I misunderstanding what you are suggesting?

--Beman


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