lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] [lmi-commits] master 9cc3f6b 05/10: Avoid passing an enum by r


From: Vadim Zeitlin
Subject: Re: [lmi] [lmi-commits] master 9cc3f6b 05/10: Avoid passing an enum by reference
Date: Thu, 8 Feb 2018 14:50:58 +0100

On Thu,  8 Feb 2018 08:40:09 -0500 (EST) Greg Chicares <address@hidden> wrote:

GC> branch: master
GC> commit 9cc3f6bde87bb01fb31f1f75a224b13bdab1d008
GC> Author: Gregory W. Chicares <address@hidden>
GC> Commit: Gregory W. Chicares <address@hidden>
GC> 
GC>     Avoid passing an enum by reference
GC>     
GC>     Removed '&' from a function's enum arguments...leaving 'const' because
GC>     the arguments must not be changed and it isn't too weird to say so.
GC> ---
GC>  basic_values.hpp | 4 ++--
GC>  ihs_basicval.cpp | 4 ++--
GC>  2 files changed, 4 insertions(+), 4 deletions(-)
GC> 
GC> diff --git a/basic_values.hpp b/basic_values.hpp
GC> index 62860da..94ec440 100644
GC> --- a/basic_values.hpp
GC> +++ b/basic_values.hpp
GC> @@ -269,8 +269,8 @@ class LMI_SO BasicValues
GC>          (std::string const& TableFile
GC>          ,e_database_key     TableID
GC>          ,bool               IsTableValid    = true
GC> -        ,EBlend      const& CanBlendSmoking = CannotBlend
GC> -        ,EBlend      const& CanBlendGender  = CannotBlend
GC> +        ,EBlend      const  CanBlendSmoking = CannotBlend
GC> +        ,EBlend      const  CanBlendGender  = CannotBlend
GC>          ) const;

 In fact I think it is too weird to say so because (as you certainly know)
this top level "const" is simply ignored in C++ and so the function
definition could still declare these parameters without "const" and modify
them if it so wished.

 As for "the arguments must not be changed" part, the same logic should
then apply to TableID and IsTableValid, yet we don't write "bool const" in
the function declaration and whatever the (negligible, IMO) merits of doing
this, it would definitely be too weird to do it.

 Regards,
VZ


reply via email to

[Prev in Thread] Current Thread [Next in Thread]