Using #import type Smart Pointers With Local Project?

Using #import type Smart Pointers With Local Project?

Post by Travis Pruit » Wed, 21 Oct 1998 04:00:00



I've got an ATL DLL server with a number of objects. These objects interact
with each other currently just great. But I'd really like the convenience of
some smart pointers, like those created by the #import directive, which wrap
variants, use the return value, etc. Is there any method to do this?

Thanks!
Travis

 
 
 

Using #import type Smart Pointers With Local Project?

Post by Alfie Kirkpatric » Thu, 22 Oct 1998 04:00:00


I don't tend to do this because it adds code size and reduces
performance in modules which are inherently "low-level". However,
you can use #import as normal, just be sure you don't use nonamespace
otherwise the generated structures will clash with your interface names.
You also need to add exception handling in your build options (which
also adds to code size).

Alfie.
--
Alfie Kirkpatrick
IMS International


>I've got an ATL DLL server with a number of objects. These objects interact
>with each other currently just great. But I'd really like the convenience
of
>some smart pointers, like those created by the #import directive, which
wrap
>variants, use the return value, etc. Is there any method to do this?

>Thanks!
>Travis


 
 
 

Using #import type Smart Pointers With Local Project?

Post by Dustin Smither » Thu, 22 Oct 1998 04:00:00


Travis,

Try CComPtr.  It's the ATL class for smart pointers.  You could do a typedef
for each class.  By the way,  if it works now it probably wont after you
introduce smart pointers :)


>I've got an ATL DLL server with a number of objects. These objects interact
>with each other currently just great. But I'd really like the convenience
of
>some smart pointers, like those created by the #import directive, which
wrap
>variants, use the return value, etc. Is there any method to do this?

>Thanks!
>Travis

 
 
 

Using #import type Smart Pointers With Local Project?

Post by Kristopher Johnso » Fri, 23 Oct 1998 04:00:00


You can #import the project's type library in the project's source files.
You will need to use a namespace or a lot of renamings to keep the "real"
interface types separate from the "wrapped" interfaces.  You may also end up
doing a lot of typecasting, because the compiler won't think that
FOOLib::IFoo is the same as ::IFoo.

-- KDJ


>I've got an ATL DLL server with a number of objects. These objects interact
>with each other currently just great. But I'd really like the convenience
of
>some smart pointers, like those created by the #import directive, which
wrap
>variants, use the return value, etc. Is there any method to do this?

>Thanks!
>Travis

 
 
 

1. STL containers, local types and pointers to incomplete types

I am using VC++ 5.0 and have encountered two annoying things in using the
STL:

1
Declaring a vector or list containing elements of a local type produces
compiler errors:

class A
{
    enum B { a, b, c };
    std::list<B> bs;
        ---compiler error in instantiation of std::list: unknown type B

2
Declaring a vector or list containing pointers to an incomplete type
produces compiler errors:

class A;

class B
{
    std::list<A *> as;
        ---compiler error: A is an incomplete type (so what?)

Do these examples represent non-conforming code or is the VC++ STL/C++
implementation non-conforming.

Any opinions are welcome!

Silvio Bierman
---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]

[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]

2. IRDA / Ericsson SH888 / DialUp Network

3. Using pointers to members with smart pointers

4. Radius Client

5. How to specialise std::swap() for Smart Pointer types?

6. Opening multiple database instances

7. Ref. Counting Smart Pointer: Conversion to Base class Smart Ptr, How?

8. smart pointers aren't so smart

9. "Smart Pointers" Not So Smart?

10. My smart pointers aren't so smart

11. "Smart Pointers" Not So Smart?