Is there a way to specify the default value std::map‘s operator[] returns when an key does not exist?
Is there a way to specify the default value std::map ‘s operator[] returns when
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, there isn’t. The simplest solution is to write your own free template function to do this. Something like:
C++11 Update
Purpose: Account for generic associative containers, as well as optional comparator and allocator parameters.