digitalmars.D.learn - Return a const structure by reference.
- Agustin (16/16) Oct 15 2013 I'm having trouble trying to return a const reference of a
- =?UTF-8?B?QWxpIMOHZWhyZWxp?= (6/21) Oct 15 2013 The two consts up there have exactly the same meaning: Even the first
I'm having trouble trying to return a const reference of a structure. public struct Structure { } public class A { private Structure structure; this(Structure structure) { this.structure = structure; } public ref const Structure getStructure() const { return structure; } } cannot implicitly convert expression (this.structure) of type const(Structure) to Structure
Oct 15 2013
On 10/15/2013 09:28 PM, Agustin wrote:I'm having trouble trying to return a const reference of a structure. public struct Structure { } public class A { private Structure structure; this(Structure structure) { this.structure = structure; } public ref const Structure getStructure() const {The two consts up there have exactly the same meaning: Even the first one qualifies the function (more correctly the implicit 'this' reference). You want this: public ref const(Structure) getStructure() const {return structure; } } cannot implicitly convert expression (this.structure) of type const(Structure) to StructureAli
Oct 15 2013