Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2003-09-01 05:48:35


Subject: [boost] Any interest in a string literal selector helper library?

> Hi all,
>
> I have written a relatively small library which I've found pretty useful
> in my own projects. I have to deal with std::basic_string objects a lot
> in my applications, and I almost always write template code so that the
> same code works with both std::string and std::wstring types. The only
> problem which cannot be directly solved with existing language construct
> is handling string literals.
>
> To make myself clear, the below code will only work for f< char >():
>
> template < typename char_type >
> void f()
> {
> std::basic_string< char_type > str( "hello" );
> }
>
> What is needed here is some facility which selects either "hello" or
> L"hello" based upon char_type. Now, using my library, the above code
> can be fixed like this:
>
> template < typename char_type >
> void g()
> {
> std::basic_string< char_type > str( TextAutoSelect( char_type, "hello"
> ) );
> }
>
I've done this before as well.
But it's a very simple function.
And I assume TestAutoSelect is a macro.
Can I take a look at the code?

Best,
John


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