creating a character width agnostic function
<p>I have a Visual Studio 2008 C++03 application where I would like to have a single function perform string operations with different parameters depending on the type of string passed in.</p>

<p>For example, if I wanted to (naively) find the path portion of a file name with something like this:</p>

<pre><code>template&lt; typename Elem, typename Traits, typename Alloc &gt;
std::basic_string&lt; Elem, Traits, Alloc &gt; GetFilePath( 
    const std::basic_string&lt; Elem, Traits, Alloc &gt;&amp; filename )
{
    std::basic_string&lt; Elem, Traits, Alloc &gt;::size_type slash = 
        filename.find_last_of( "\\/" ) + 1;
    return filename.substr( 0, slash );
}
</code></pre>

<p>for wchar_t based strings, it would use <code>L"\\/"</code> and for char based strings <code>"\\/"</code>.</p>

<p>And the calling convention would be something like this:</p>

<pre><code>std::wstring pathW = GetFilePath( L"/Foo/Bar/Baz.txt" );

std::string pathA = GetFilePath( "/Foo/Bar/Baz.txt" );
</code></pre>

<p>Can anybody suggest how to modify the above function for this goal? (Yes, I realize I could have two functions that overload the <code>GetFilePath</code> name. I would like to avoid that, if possible.)</p>
