What is the difference regarding memory allocation and efficiency between using a struct with two fields and a pair?
What is the difference regarding memory allocation and efficiency between using a struct with
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.
std::pairprovides pre-written constructors and comparison operators. This also allows them to be stored in containers like std::map without you needing to write, for example, the copy constructor or strict weak ordering viaoperator <(such as required bystd::map). If you don’t write them you can’t make a mistake (remember how strict weak ordering works?) so it’s more reliable just to usestd::pair.