On Sun, Nov 16, 2008 at 5:14 PM, Christian Kamm <[EMAIL PROTECTED]> wrote: >> I have an interesting issue, that makes me curious on how D handles it. >> >> (Traits template code) > > You cannot spread out template specializations across modules. If you define > > template Trait(T : S); in a.d and > template Trait(T : C); in b.d and try to use > alias Trait!(S) sinst; in use.d, you'll get > Error: a.Trait(T : S) at a.d(3) conflicts with b.Trait(T : C) at b.d(3) > > because the two Traits live in separate scopes. This makes C++ style trait > templates just not work in D. > > Does anyone know an equivalent?
I think what Ryan said there is the general approach you have to take. Don't specialize the traits template, but rather pass in a whole new template as an alias parameter to the main template. This would be a good thing to add here: http://www.prowiki.org/wiki4d/wiki.cgi?PortingFromCxx Is there some canonical example of where you use specialized traits templates in C++? Or is this maybe a more general issue, like porting ADL code in C++. Not traits templates, but another ADL example is how you see IO done often in C++. With overloads for some common function like "write(Stream& o, ModuleSpecificType& val)". This pattern doesn't translate directly to D either. Suggestions? --bb
