From: Dean M. B. <mik...@gm...> - 2008-10-13 12:31:56
|
On Mon, Oct 13, 2008 at 8:05 PM, Kim Gräsman <kim...@gm...> wrote: > > I wonder if what Glyn is looking for is something like: > > template <> char_based_traits<network::tags::default_> { > typedef std::string string_type; > typedef std::ostringstream ostringstream_type; > typedef char char_type; > }; > > so that related traits are defined together, and orthogonal traits > separately. Just guessing, though. But it doesn't make intuitive sense > to me to specialize them separated from each other, when they're all > based on the definition of char. > This is the same problem the standard iterator traits introduce -- a blob -- which is bad design, and very unwieldy. I think I've discussed this before as to why I don't like trait blobs and why I prefer individual trait types. It has something to do with extensibility and for enforcing good design. At any rate, it _should_ remain as individual types instead of blobs precisely because you only need to specify the trait supported -- sometimes it doesn't make sense to support for instance a 'transfer_buffer' trait type for other traits since it only applies to protocol traits which involve customization of the transfer_buffer<...>::type based on the tag. Some traits don't need to be specialized for certain tags, and mis-using these traits with unsupported tags should yield a clear compile-time error which says that a specialization for a certain trait type cannot be found. -- Dean Michael C. Berris Software Engineer, Friendster, Inc. |