Skip to content

Conversation

@longjon
Copy link
Contributor

@longjon longjon commented Jan 7, 2015

Net currently has a somewhat lackluster use of const. Returned references should be const; it's not okay to modify the referents. Accessors and some other functions can be const methods; it is okay to call them on const Nets.

A few changes need to be made to fix existing code. In particular std::map::operator[] is not a const method, so the somewhat more obscure find(...)->second needs to be used instead in a couple places.

(I need a few of these for a future PR, so I went ahead and took a pass over the whole Net interface.)

If you find any of this constness too intrusive, discuss.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This const feels wrong from a logical perspective. It clearly modifies the current network.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, I was thinking this went the other way, thanks for pointing that out. I guess there is some subtle reason why the compiler does not generate any warnings in this case. I'll push a corrected version shortly...

@jeffdonahue
Copy link
Contributor

LGTM

longjon added a commit that referenced this pull request Jan 16, 2015
@longjon longjon merged commit c24c83e into BVLC:dev Jan 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants