$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Beman Dawes (bdawes_at_[hidden])
Date: 2008-05-20 09:13:02
Alexei Alexandrov wrote:
> Hi,
> 
> in several places I need to have code which works both with char and 
> wchar_t. Those are template functions. I also work with paths there so I 
> wanted to actually write something like
> 
> template <typename CharType>
> void foo(const std::basic_string<CharType>& s)
> {
>      typedef fs::basic_path<std::basic_string<CharType> > path_type;
>      ...
> }
> 
> but it turned out that I can't do it because 1) basic_path has the 
> second Traits template parameter mandatory and 2) this Traits parameter 
> has actually different type for path and wpath:
> 
>      struct path_traits;
>      typedef basic_path< std::string, path_traits > path;
>      // ...
>      struct BOOST_FILESYSTEM_DECL wpath_traits;
>      typedef basic_path< std::wstring, wpath_traits > wpath;
> 
> Of course, I can easily workaround it with my own traits, but I wonder 
> could it be in the first place like:
> 
>      template<class String>
>      class basic_path_traits;
> 
>      template<class String, class Traits = basic_path_traits<String> >
>      class basic_path;
> 
> with basic_path_traits being specialized for std::string and 
> std::wstring and fs::path and fs::wpath being just
> 
>      typedef basic_path< std::string > path;
>      typedef basic_path< std::wstring > wpath;
I've created ticket #1936 with the above.
There are two perspectives to consider at this issue.
* As a very specific tweak to the current interface.
* As a further indication that there should be a single path type that 
can handle both wide and narrow types. Peter Dimov suggested that once, 
and I keep turning over in my mind how it could be accomplished. With 
C++0x supplying two new character types, the need becomes more pressing. 
I still don't want to invent a solution that applies only to filesystem 
paths; there is a general need for strings that can cope with multiple 
character types and encodings.
Thanks,
--Beman