digitalmars.D.learn - const-correct structs, best practices?
- Nick Sabalausky (3/3) Aug 21 2015 Is there a good posting somewhere that summarizes the current best
- Meta (2/5) Aug 21 2015 Prepare for pain.
- Dicebot (4/7) Aug 21 2015 - mark methods const
- Nick Sabalausky (5/12) Aug 21 2015 What about inout?
- Steven Schveighoffer (7/21) Aug 21 2015 inout should work when returning a piece of the struct. I found it
Is there a good posting somewhere that summarizes the current best practices for making const-correct (ie works for all of mutable/const/immutable) structs?
Aug 21 2015
On Friday, 21 August 2015 at 15:00:04 UTC, Nick Sabalausky wrote:Is there a good posting somewhere that summarizes the current best practices for making const-correct (ie works for all of mutable/const/immutable) structs?Prepare for pain.
Aug 21 2015
On Friday, 21 August 2015 at 15:00:04 UTC, Nick Sabalausky wrote:Is there a good posting somewhere that summarizes the current best practices for making const-correct (ie works for all of mutable/const/immutable) structs?- mark methods const - avoid reference type fields ;)
Aug 21 2015
On 08/21/2015 12:22 PM, Dicebot wrote:On Friday, 21 August 2015 at 15:00:04 UTC, Nick Sabalausky wrote:What about inout? I have a struct that supports operator overloading, returning the struct's own type. After fiddling with that, I got a good laugh out of Meta's comment, and I think he may be right!Is there a good posting somewhere that summarizes the current best practices for making const-correct (ie works for all of mutable/const/immutable) structs?- mark methods const - avoid reference type fields ;)
Aug 21 2015
On 8/21/15 12:31 PM, Nick Sabalausky wrote:On 08/21/2015 12:22 PM, Dicebot wrote:inout should work when returning a piece of the struct. I found it incredibly easy when instrumenting dcollections. Just use it like you would const. Where you are going to run into problems is if you have things like ranges that need to partially cast to const. -SteveOn Friday, 21 August 2015 at 15:00:04 UTC, Nick Sabalausky wrote:What about inout? I have a struct that supports operator overloading, returning the struct's own type. After fiddling with that, I got a good laugh out of Meta's comment, and I think he may be right!Is there a good posting somewhere that summarizes the current best practices for making const-correct (ie works for all of mutable/const/immutable) structs?- mark methods const - avoid reference type fields ;)
Aug 21 2015