TITLE: compile-time structure decision (Newsgroup: comp.lang.c++.moderated, 10 Jan 2000) ALEXANDRESCU: "Andrei Alexandrescu" >> By the way, now that the rant is on, structure variations are >> easier to implement with the help of either private inheritance, >> inner classes with total specialization, and/or this little structure: >> >> template >> struct Choice >> { >> typedef T Type; >> }; >> >> template >> struct Choice >> { >> typedef U Type; >> }; ABRAHAMS: Dave Abrahams > Care to elaborate? It's not clear at all how you intend to use this. ALEXANDRESCU: "Andrei Alexandrescu" Sorry. The intent of Choice is to choose a type or another depending on a boolean parameter. This allows you to tweak the structure depending on a compile-time expression, like this: enum ThreadingModel { singleThreaded, multiThreadedClassLevel, multiThreadedObjectLevel }; template class Something { typedef Choice, Lock>::Type>::Type ThreadingController; ThreadingController lock_; ... }; ALEXANDRESCU: >> It just happens that tweaking behavior is a lot harder >> because of this curious little hole in the template system. >> I dream I could convince some influent people about this :o). ABRAHAMS: > When you say "hole" you're not referring to your Choice template > above, are you? I presume you mean the problem originally raised... ALEXANDRESCU: I referred to the hole being the lack of PTS at the level of member functions. [snip] [ PTS = partial template specialization --adc ] _______________________________________________ cpptips mailing list http://cpptips.hyperformix.com