how can i get the type of the elements that are held by a STL container?
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.
For containers in general it will be
X::value_type. For associative containers it will beX::mapped_type(X::value_typecorresponds topair<const Key,T>). It is according to Chapter 23 of C++ Standard.To check that types are equal you could use
boost::is_same. And since C++11 —std::is_same.