Boost logo

Boost :

From: Alexei Alexandrov (alexei.alexandrov_at_[hidden])
Date: 2008-05-20 00:10:23


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;

?

Thanks.

-- 
Alexei Alexandrov

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk