Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost::interprocess::string problems
From: Ion Gaztañaga (igaztanaga_at_[hidden])
Date: 2010-07-23 11:22:44

On 23/07/2010 15:45, this_thread wrote:
> I can't seem to get the hang of strings though. I've looked around online
> and can't seem to find an example of how this should be set up, and I can't
> get it to accept an allocator. The only way I can seem to typedef one is
> something like:
> typedef boost::interprocess::string BoostString
> - or -
> typedef boost::interprocess::basic_string<char> BoostString;

Just as any container, interprocess basic_string needs an allocator, but
it's the third argument (just like std::string, by the way) :

template<typename CharT, typename Traits, typename A>
class basic_string;

so defint it like this:

using namespace boost::interprocess;
typedef basic_string<char, std::char_traits<char>, allocator_type>

As with vector, you will need to pass an allocator to the string
cosntructor. See also string_test.cpp test in
boost/libs/interprocess/test for an example of shared memory strings.



Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at