Suppose I have a library and multiple projects dependent on that library. The library headers already has some partial class specializations. I want to allow each dependent project to override with its own partial specializations. I need to achieve this all statically for performance reasons. Some simplified code is below.
Library code:
template <class A, class B, class Enable=void>
struct Widget;
struct Foo
{
};
template <class B>
struct Widget<Foo, B>
{
};
User code:
template <class B>
struct DoSpecialize;
template <class B>
struct Widget<Foo, B, enable_if< DoSpecialize<B> >::type
{
};
The problem here is we end up with multiple definitions of the same specialization. I think we need a disable_if<>
somewhere. How could we avoid this?