
On Wed, Oct 29, 2008 at 11:33 PM, Edward Diener <eldiener@tropicsoft.com>wrote:
Beman Dawes wrote: ... The issue for me was just ease of instantiation of a basic_path based solely on a string type ( which is actually a character type ). One can not currently instantiate a basic_path with:
boost::filesystem::basic_path<std::basic_string<char>, boost::filesystem::basic_trait<std::basic_string<char> > > myPath;
where one just specifies the character type.
Why would one want to do that ? For two reasons:
1) In a VC++ program which may be multibyte or Unicode depending on a compiler option, we would have:
boost::filesystem::basic_path<std::basic_string<_TCHAR>, boost::filesystem::basic_trait<std::basic_string<_TCHAR> > > myPath;
2) A template class or template function taking a character type parameter would just pass that type in to filesystem to instantiate the correct type path.
So I do not know whether your version 3 solves makes that easier or not, but hopefully it does.
Here is an example; this code does compile and run correctly under V3: #include <boost/filesystem/path.hpp> #include <boost/filesystem/operations.hpp> #include <string> #include <cassert> #include <windows.h> #include <winnt.h> namespace fs = boost::filesystem; typedef std::basic_string<TCHAR> tstring; void func( const fs::path & p ) { assert( fs::exists( p ) ); } int main() { // get a path that is known to exist fs::path cp = fs::current_path(); // demo: get tstring from the path tstring cp_as_tstring = cp.string<tstring>(); // demo: pass tstring to filesystem function taking path assert( fs::exists( cp_as_tstring ) ); // demo: pass tstring to user function taking path func( cp_as_tstring ); return 0; } --Beman