Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost::interprocess::string problems
From: this_thread (cdail.forums_at_[hidden])
Date: 2010-07-26 12:41:29


Ion Gaztañaga 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;
>
> so defint it like this:
>
> using namespace boost::interprocess;
> typedef basic_string<char, std::char_traits<char>, allocator_type>
> shm_string;
>
> 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.
>
>

I'm still having a little trouble. The allocator they use in
string_test.cpp is one totally implemented there for that project; I'm not
going to have to do / copy that am I? I've tried:

typedef boost::interprocess::basic_string<char, std::char_traits<char>,
boost::interprocess::allocation_type> BoostString;

AND:

typedef boost::interprocess::allocator<char,
boost::interprocess::managed_shared_memory::segment_manager> CharAllocator;
typedef boost::interprocess::basic_string<char, std::char_traits<char>,
boost::interprocess::CharAllocator> BoostString;

Neither of these bite, I get compiling errors... "allocator_type" doesn't
work / isn't defined (even with boost::interprocess qualifier). Am I
missing something?

-- 
View this message in context: http://old.nabble.com/Boost%3A%3Ainterprocess%3A%3Astring-problems-tp29206125p29268474.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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