On 01.06.19 14:51, David Zhang wrote:
     struct S {
         /*const*/ char* pointer;
         ... other members ...

         this(/*const*/ char* p, ... others ...) {
             pointer = p;
             ...
         }
     }

What I want, is to be able to use `S` in other data structures with the following properties checked by the compiler:

  - The variable can be set
  - The variable can be read
  - The variable cannot be modified, only replaced

How is setting/replacing different from modifying?

Is there a type-safe way to do this? If this were a class, I'd try std.typecons.Rebindable.

struct S
{
    const(char)* pointer;
    /* ... */
}

Reply via email to