std.allocator needs your help

sclytrack sclytrack at layout.com
Wed Sep 25 12:10:17 PDT 2013


On Wednesday, 25 September 2013 at 01:22:46 UTC, deadalnix wrote:
> On Tuesday, 24 September 2013 at 15:57:00 UTC, Andrei 
> Alexandrescu wrote:
>> Also, I hope we'll be able to allow allocators to define 
>> Pointer(T), Ref(T) etc. that supplant replacements for the 
>> built-in notions of pointer, reference etc. Then, user code 
>> that uses these notions instead of the built-in ones will be 
>> guaranteed some nice properties (e.g. automatic reference 
>> counting). Unfortunately I don't see a way for an allocator to 
>> enforce that its users don't do illegal things such as 
>> escaping addresses etc. So it would be a discipline-backed 
>> scheme. Notable beneficiaries will be containers.
>>
>
> It will be fun without tail const.
>

Do you mean something like this?

struct StructName1
{
   int a;
}

struct StructName2
{
   const int a;
}

StructName1 a;
StructName2 b;
b = a;  //does not work

Struct sorta like typedef on the name. Nothing to make sure that 
it is the
same field layout, regardless of const.


struct LayoutName1, StructName1
{
   int a;
}

struct LayoutName1, StructName2
{
   const int a;
}



More information about the Digitalmars-d mailing list