Boost logo

Boost :

Subject: Re: [boost] Warning policy? local variable hides (i.e. shadows) globalvariable
From: Beman Dawes (bdawes_at_[hidden])
Date: 2015-01-15 11:34:48


On Thu, Jan 15, 2015 at 10:24 AM, Peter Dimov <lists_at_[hidden]> wrote:
> Beman Dawes wrote:
>
>> Should Boost have policy to clear these warnings?
>
>
> I found one place where -Wshadow was quite annoying.
>
> class error
> {
> private:
>
> std::string name_, reason_;
>
> public:
>
> error( std::string const & name, std::string const & reason ):
> name_( name ), reason_( reason ) {}
>
> std::string name() const { return name_; }
> std::string reason() const { return reason_; }
> }
>
> The name() member function is shadowed by the constructor parameter. I can't
> use name_ for the parameter because of the member. I don't want to use _name
> for the parameter because the leading underscore is legal but for obscure
> reasons. So I was forced to use abbreviations like nm and rsn, which isn't
> very readable.

Agreed.

I'm hoping that we can figure some decoration. I've used "name_arg" /
"reason_arg" style once in a while, although that is a bit
long-winded.

--Beman


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk