On Wednesday, 7 May 2014 at 18:41:17 UTC, Maxime Chevalier-Boisvert wrote:
Basically, I just want to create a wstring "view" on an existing "raw" buffer that exists in memory somewhere, based on a pointer to this buffer and its length.

Looks like you actually don't need to allocate anything at all. Any slice is just a struct with 2 fields, it does not own data and can be used as a view to anything:

void* some_external_data;
size_t external_length;

void foo()
{
auto str = cast(wstring[])(some_external_data[0..external_length]); // this will create a stack instance of slice struct with `.ptr` field pointing to same address as `some_external_data`
}

Reply via email to