|
From: Dean M. B. <mik...@gm...> - 2007-07-18 09:24:03
|
Hi Glyn!
On 7/17/07, Glyn Matthews <gly...@gm...> wrote:
> Guys,
>
> I've been giving a little thought to something Dean mentioned in his last
> message about using std::string in the network library.
>
> The first thing I thought of was that Dean stated that "everything is a
> template". Apart of course from std::string. I have created a branch in
> SVN named gxm) which replaces all references to std::string with an extra
> template parameter. Happily, this passes all the original tests (with an
> additional template specialization so that const char * is converted to a
> std::string). However, this creates a problem (certainly with GCC) because
> the wchar_t typedef is the same as char and its not possible to overload
> const wchar_t * in the same way. So the following code will not compile:
>
> wmessage wmsg;
> wmsg << header(L"wide characters");
>
> Another thing I see is that boost filesystem and boost program_options have
> dealt with a very similar problem to this. But if we use the same approach
> (see the file "boost/detail/utf8_codecvt_facet.hpp" ) then
> we'd have to accept the use of a cpp source file, meaning we will no longer
> have a header only library.
>
> What do others think about this?
>
I haven't checked out your code yet, but I'm excited to see how this
works (or breaks). :)
Our problem primarily here is that header(L"key", L"value") is an
inline method which returns a specific instance of type
header_directive<tags::default_>. Now if we overloaded that inline
method with say something like:
inline impl::header_directive<tags::unicode>
header(typename tags::unicode::str_type const & header_name,
typename tags::unicode::str_type const & header_value) {
return impl::header_directive<tags::unicode>(header_name,
header_value);
};
And then do a typedef such as:
typedef basic_message<tags::unicode> message_w ;
typedef basic_message<tags::unicode> wide_message ;
typedef basic_message<tags::unicode> message_wide ;
We'd also like to then have tags::unicode typedef the correct type for
the string as 'str_type'. That way we can customize just tags::unicode
for different platforms, and have the check for GCC implement the
correct type there.
Would you think that works? I hope I made sense... :D
(Cheng, I will indulge you with that request from the other email...
Let me write down my thoughts.) :)
--
Dean Michael C. Berris
http://cplusplus-soup.blogspot.com/
mikhailberis AT gmail DOT com
+63 928 7291459
|