Boost logo

Boost Users :

Subject: Re: [Boost-users] [filesystem] basic_path as parameter
From: Alexander Lamaison (awl03_at_[hidden])
Date: 2010-03-09 12:57:05


On Tue, 09 Mar 2010 09:38:32 -0800, Steven Watanabe wrote:

> Alex Lamaison wrote:
>> I'd like to use basic_path as a function parameter so that it works
>> correctly whether a wide or narrow string is passed.
>>
>> template<typename T>
>> void func(basic_path<T> file) { do thing to file }
>>
>> func("myfile");
>> func(L"myfile");
>
> Try specializing for char and wchar_t instead of char* and wchar_t*.
> You could also just use
>
> template<typename T, typename Traits>
> void func(const basic_bath<T, Traits>& file);

Thanks Steven. I tried both of these but still no luck.

For this definition:

template<typename T, typename Traits>
inline hmodule load_library(
    const boost::filesystem::basic_path<T, Traits>& library_path) {}

called like this:

load_library("kernel32.dll");
load_library(L"kernel32.dll");

I get this error (namespaces stripped):

"error C2784: 'hmodule load_library(const basic_path<String,Traits> &)' :
could not deduce template argument for 'const basic_path<String,Traits> &'
from 'const char [13]'"

and similar for wchar_t[13].

What can I do to help its powers of deduction?

Alex

P.S. Sorry for all the dupes; GMANE issues :(


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net