"Alvin777" <al******@mail.ru> wrote in message
news:1c**************************@posting.google.c om...
I'd like to have data file with many strings and load them at once
using MapViewOfFile[Ex] and unload with UnmapViewOfFile. So I wouldn't
have to allocate memory for each string on heap.
How can I use basic_string<> attaching them to pointer to string
within mapped space so it wouldn't copy that string to internal
buffer?
You cannot. Obviously there would be difficulties if, for instance,
std::string wanted to reallocate its buffer. It would be awkward to keep
track of whether it had a reallocated buffer, or one that was supplied by
the user.
I suggest you write your own string class that does what you want
(presumably one that never reallocates its buffer).
class StaticString
{
public:
StaticString(const char*);
...
private:
const char* buffer;
};
john