Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2005-09-15 09:52:25

Alec Ross wrote:
>In message <dgbrjk$k7r$1_at_[hidden]>, Adam Badura <abadura_at_[hidden]>
> >2) using own classes instead of standard (most common for string)
> >and MFC for example)
>wxWidgets has a wxString class: but you can use a std::string as well;
>and wxWidgets may well migrate to using std::string. Currently it is
>forward compatible, to the extent that it implements most of the
>std::string functions.
>But I take the point that wxWidgets and MFC currently have native types
>that (approximately) duplicate the std versions.

Also, there is nothing stopping you doing:

   window.SetText( std::string( "Hello World" ).c_str());


   ATL::CString text;
   window.GetText( text );
   return std::string( static_cast< const char * >( text ));

If you want to use TCHAR's:

   typedef std::basic_string< TCHAR > _tstring;

so you could have:

   namespace boost { namespace gui
#if defined(BOOST_WINDOWS) || defined(BOOST_HAS_TCHAR)
      typedef std::basic_string< TCHAR > string;
      typedef std::string string;

Then you can use gui::string in a generic, cross-platform way. Granted, it
is (slightly) more work, but there is no need to use the string types
provided by a particular GUI framework.

- Reece Haston Dunn
Software Engineer, Sophos

Boost list run by bdawes at, gregod at, cpdaniel at, john at