From: Dean M. B. <mik...@gm...> - 2008-10-13 10:46:01
|
Hi Glyn, On Mon, Oct 13, 2008 at 5:47 PM, Glyn Matthews <gly...@gm...> wrote: > > 2008/10/13 Kim Gräsman <kim...@gm...> >> >> On Mon, Oct 13, 2008 at 04:04, Dean Michael Berris >> > That raises a good issue though: should we have a single place to have >> > the tags hierarchy depicted? >> > [snip code] >> >> It feels a little strange pushing the tags together, but I can't say >> why, really... It creates sort of a hotspot, where everybody will have >> to make edits in order to add new protocols, etc. That's probably not >> a huge problem. > > It could be a problem. I share your concern about this. But I don't know a > solution to this yet. > Yeah, I thought about it a little more, and instead of using a 'struct tags' I think it should remain a namespace. So it'd look like: namespace network { namespace tags { struct default_ { }; } } That way we can add more tags to this central namespace as protocols get implemented along the way. >> >> > That way we can build traits on top of this hierarchy under a >> > different namespace 'traits': >> > >> > namespace network { namespace traits { >> > template <class Tag> string; >> > template <class Tag> buffer; >> > template <class Tag> ostringstream; >> > template <class Tag> char_; >> > // ... >> > } } >> >> I think it makes sense to keep the traits together, there's bound to >> be a lot of overlap (especially around strings). > > right. But I think it might be better named: > namespace network { namespace traits { > template <class Tag> string_type; > template <class Tag> buffer_type; > template <class Tag> ostringstream_type; > template <class Tag> char_type; > }} > The _type will then be redundant for using traits: template <> struct string_type<network::tags::default_> { typedef std::string type; }; //... string_type<>::type instance; // ugly? redundant _type and ::type? > On an unrelated note, doesn't using ostringstream always require > basic_string? And char_type is not orthogonal to string_type and char_type. > template <> string<network::tags::default_> { typedef std::string type; }; template <> struct string<network::tags::wide_default_> { typedef std::wstring type; }; template <> struct ostringstream<network::tags::default_> { typedef std::ostringstream type; }; template <> struct ostringstream<network::tags::default_> { typedef std::wstringstream type; }; :-D -- Dean Michael C. Berris Software Engineer, Friendster, Inc. |