From: willhouse86 on
Hello,

I'm creating a "wrapper" library interface for a third party library.
One
of my reasons for designing such an interface is to remove the third
party header file dependency for users of my library. I am able to do
this by using only references to the third party library objects in my
header files and forward declaring the corresponding classes.

In some cases, the third party library uses one of their typedefs for
an STL container of pointers. I'm able to include the header for the
container (<vector>) and forward declare the pointer classes to
avoid the inclusion of the third party header file(s), but in doing so
I am ignoring the typedef used by their code. Is this considered
bad practice?

willhouse




From: James Dennett on
willhouse86(a)gmail.com wrote:
> Hello,
>
> I'm creating a "wrapper" library interface for a third party library.
> One
> of my reasons for designing such an interface is to remove the third
> party header file dependency for users of my library. I am able to do
> this by using only references to the third party library objects in my
> header files and forward declaring the corresponding classes.
>
> In some cases, the third party library uses one of their typedefs for
> an STL container of pointers. I'm able to include the header for the
> container (<vector>) and forward declare the pointer classes to
> avoid the inclusion of the third party header file(s), but in doing so
> I am ignoring the typedef used by their code. Is this considered
> bad practice?

There's no trivial answer: this can be problematic. It might
be OK, or you might be better off completely wrapping their
header file with your own interface so that there's doesn't
"leak through" at all.

-- James
From: Jim Langston on
willhouse86(a)gmail.com wrote:
> Hello,
>
> I'm creating a "wrapper" library interface for a third party library.
> One
> of my reasons for designing such an interface is to remove the third
> party header file dependency for users of my library. I am able to do
> this by using only references to the third party library objects in my
> header files and forward declaring the corresponding classes.
>
> In some cases, the third party library uses one of their typedefs for
> an STL container of pointers. I'm able to include the header for the
> container (<vector>) and forward declare the pointer classes to
> avoid the inclusion of the third party header file(s), but in doing so
> I am ignoring the typedef used by their code. Is this considered
> bad practice?

A pointer is one of the things that can usually be safely forward declared
without having to include the complete specification. If the user has no
need for the details of what the pointer is pointing to, this is probably
fine and desirable. No need to expose the internal workings uneccesarrily.

--
Jim Langston
tazmaster(a)rocketmail.com