On Saturday, 12 March 2016 at 15:32:39 UTC, Mike Parker wrote:
On Saturday, 12 March 2016 at 14:02:31 UTC, user42 wrote:
Why is this thing not compiling ?
Or, in other words, how is is possible to log something to a
file from a const member function ?
Const member functions functions are
On Saturday, 12 March 2016 at 14:02:31 UTC, user42 wrote:
Why is this thing not compiling ?
Or, in other words, how is is possible to log something to a
file from a const member function ?
Const member functions functions are not allowed to mutate any
member state at all. This includes
return s;
}
}
void main()
{
auto x = new X;
auto y = new Y;
import std.conv: to;
x.p(to!string(y));
}
Why is this thing not compiling ?
Or, in other words, how is is possible to log something to a file
from a const member function ?
Thanks in advance
On Monday, February 23, 2015 09:12:33 rumbu via Digitalmars-d-learn wrote:
> On Saturday, 21 February 2015 at 15:26:28 UTC, ketmar wrote:
> > On Sat, 21 Feb 2015 08:27:13 +, rumbu wrote:
> >
> >> My question was not how I do this, I know already. My question
> >> was if
> >> there is another wa
On Mon, 23 Feb 2015 09:12:33 +, rumbu wrote:
> On Saturday, 21 February 2015 at 15:26:28 UTC, ketmar wrote:
>> On Sat, 21 Feb 2015 08:27:13 +, rumbu wrote:
>>
>>> My question was not how I do this, I know already. My question was if
>>> there is another way to safely call a non-const insta
On Saturday, 21 February 2015 at 15:26:28 UTC, ketmar wrote:
On Sat, 21 Feb 2015 08:27:13 +, rumbu wrote:
My question was not how I do this, I know already. My question
was if
there is another way to safely call a non-const instance
function on a
const object.
is there a way to been saf
On Saturday, 21 February 2015 at 15:26:28 UTC, ketmar wrote:
On Sat, 21 Feb 2015 08:27:13 +, rumbu wrote:
My question was not how I do this, I know already. My question
was if
there is another way to safely call a non-const instance
function on a
const object.
is there a way to been saf
On Saturday, 21 February 2015 at 06:38:18 UTC, rumbu wrote:
Often I'm using the following code pattern:
class S
{
private SomeType cache;
public SomeType SomeProp() @property
{
if (cache is null)
cache = SomeExpensiveOperation();
return cache;
}
}
Is there any w
On Sat, 21 Feb 2015 08:27:13 +, rumbu wrote:
> My question was not how I do this, I know already. My question was if
> there is another way to safely call a non-const instance function on a
> const object.
is there a way to been safely hit by a truck?
signature.asc
Description: PGP signature
On Saturday, February 21, 2015 08:27:13 rumbu via Digitalmars-d-learn wrote:
> On Saturday, 21 February 2015 at 08:08:25 UTC, Mike Parker wrote:
> > On 2/21/2015 4:31 PM, rumbu wrote:
> >
> > you can do this instead:
> >
> > this() { cache = SomeExpensiveOp(); }
> >
> > public @property con
On Saturday, 21 February 2015 at 07:31:19 UTC, rumbu wrote:
On Saturday, 21 February 2015 at 07:01:12 UTC, Baz wrote:
---
class S
{
private SomeType cache;
public const(SomeType) SomeProp() @property
{
if (cache is null)
cache = SomeExpensiveOperation();
return cach
On Saturday, 21 February 2015 at 08:08:25 UTC, Mike Parker wrote:
On 2/21/2015 4:31 PM, rumbu wrote:
you can do this instead:
this() { cache = SomeExpensiveOp(); }
public @property const(int) SomeProp() const
{
return cache;
}
Notice the const on the end of SomeProp. T
On 2/21/2015 4:31 PM, rumbu wrote:
My intention is not to have a read-only getter, I want to call SomeProp
on a const object:
class S
{
private int cache = -1;
private int SomeExpensiveOp() { return 12345; }
public @property const(int) SomeProp()
{
if (cache = -1)
On Saturday, 21 February 2015 at 07:01:12 UTC, Baz wrote:
---
class S
{
private SomeType cache;
public const(SomeType) SomeProp() @property
{
if (cache is null)
cache = SomeExpensiveOperation();
return cache;
}
}
---
the result of the getter will be read-o
---
class S
{
private SomeType cache;
public const(SomeType) SomeProp() @property
{
if (cache is null)
cache = SomeExpensiveOperation();
return cache;
}
}
---
the result of the getter will be read-only
Often I'm using the following code pattern:
class S
{
private SomeType cache;
public SomeType SomeProp() @property
{
if (cache is null)
cache = SomeExpensiveOperation();
return cache;
}
}
Is there any way to mark SomeProp() as const? Because I want to
call somew
16 matches
Mail list logo