Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dict<K,V> does not have const operator[] #76

Closed
jeremysalwen opened this issue Aug 24, 2015 · 1 comment
Closed

dict<K,V> does not have const operator[] #76

jeremysalwen opened this issue Aug 24, 2015 · 1 comment

Comments

@jeremysalwen
Copy link

It might be nice to have a const operator[] in the dict class, for accessing elements from const dicts.

@cliffordwolf
Copy link
Collaborator

T& dict<>::operator[](const K &key) creates the entry with its default constructor when it is not already in the dict. You can't do that with a const dict<>. Use const T& dict<>::at(const K &key) const to access an already existing entry (throws std::out_of_range for non existing entries).

kamilrakoczy referenced this issue in antmicro/yosys Jun 29, 2020
[pull] master from YosysHQ:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants