There's a hidden metafunction in there which takes a type T
and returns Fwk::Ptr< T >
. You have implemented this metafunction twice. Implementing it inside the classes introduces a false dependency of the metafunction upon the classes.
To remove this false dependency, implement the metafunction before anything else.
template< typename T >
using FwkPtr = Fwk::Ptr< T >;
(Edit: here is a C++03 style metafuction.
template< typename T >
struct FwkPtr {
typedef Fwk::Ptr< T > type;
};
Then you would refer to FwkPtr< Segment >::type
, or if the metafunction is applied to a template parameter or result thereof, typename FwkPtr< T >::type
.)
If in the future Segment
and Location
are templated so their Ptr
members could be something else, then the problem goes away because of delayed evaluation. But the fix still works, and it's still conceptually valid.
You might (ultimately) have the metafunction compute something else, or have more than one metafunction. The point is that you don't need the entire class to do it, and it's not a functionality encapsulated by the class.
On the other hand, if the arguments will always certainly be Fwk::Ptr< Segment >
and Fwk::Ptr< Location >
, you can just specify them that way and sidestep the issue.