Subject: Re: [boost] interprocess with unordered_map
From: Joel (jdy_at_[hidden])
Date: 2012-03-17 00:53:27
Ion GaztaÃ±aga <igaztanaga <at> gmail.com> writes:
> El 15/03/2012 23:18, Olaf van der Spek escribiÃ³:
> > 2012/3/15 Ion GaztaÃ±aga<igaztanaga <at> gmail.com>:
> >> El 15/03/2012 3:14, Joel Young escribiÃ³:
> >>> Can the interprocess::basic_string be modified to allow these conversions?
> >>> I hate having to do:
> >>> key_val = "fruitcake";
> >>> db.find(key_val);
> >> place the string in shared memory. I don' think it could be implicitly
> >> constructible from char* or std::string.
My code above used the assignment operator to convert it. The constructor can
do it also. If not, then at least provide a convenience function to do it!
> > But there's no (good) reason for the input to be required to be in
> > shared memory.
Exactly. I've got my container in the mapped file or shared memory. Why should
I want to clutter up the shared memory with a temporary? Especially if I'm just
doing a find in a read-only chunk of memory!
> A shared memory allocator is designed to allocate from a managed shared
> memory segment. And this requires a base address of that shared memory
> segment . And even with std::string you need to build a temporary string
> to compare it with the ones stored in the container.
But the temporary string isn't used for anything! I create a temporary string,
allocated into a DIFFERENT memory pool and it works just fine. If I can create
an arbitrary basic_string with an allocator to a random place to serve as a
temporary, the library can darn well do it too!
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk