From: stephan b. <st...@s1...> - 2004-12-25 16:59:56
|
We could use traits. template <typename SharedLibImplTag> HandleTraits { typedef unsigned long handle_type; } Inside SharedLib.ltdl.cpp we define the following: template <> HandleTraits<lt_handle_t> // or some internal marker type { typedef lt_handle_t handle_type; } And in SharedLib's impl we reference _handle via the traits type. The problem with that is that client code using SharedLib.ltdl only has access to HandleTraits's *default* implementation, because the specialization must live in hidden impl code. This means that clients won't be able to get at the handle in it's native form. This isn't a bad thing, but it means that the handle() function in SharedLib.ltdl would still need to return the default handle_type. That means that we're still basically stuck with not being able to pass the handle back to the client properly (currently requires 2 casts: one to void *, then one to ulong). Or we could put the traits types in public headers and #ifdef the proper specialization(s) in. One idea might be making a base class for SharedLib: AbstractSharedLib<HandleT> SharedLib : public AbstractSharedLib<ulong> SharedLibLtDl : public AbstractSharedLib<lt_handle_t> i don't know if this buys us any flexibility, though. ??? -- ----- st...@s1... http://s11n.net "...pleasure is a grace and is not obedient to the commands of the will." -- Alan W. Watts |