Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • 2
    Passing in all related types as parameter seems like a messy solution. Perhaps it's the only way though... Commented Jul 19, 2013 at 21:53
  • Is your Parent object the same for every type? Then you can remove the TParent generic parameter and just use IRelated<SomeBaseClass> Commented Jul 19, 2013 at 21:54
  • No, it's different for each type : / which is sort of the crux of the problem as this is a simplified example. Imagine that there's a TParent, TChild, TThis, TThat, all related to any parameter type. The collection of required dependent types is often called concepts in c++ template world. Commented Jul 19, 2013 at 21:56
  • There are a lot of options for cleaning this up. If you construct the objects using a factory, you can probably use type inference to make the syntax cleaner. Commented Jul 19, 2013 at 22:00