By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,422 Members | 1,282 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,422 IT Pros & Developers. It's quick & easy.

[Warning] passing `const double' for converting

P: 71
I get this long and hard to understand warning when I call a constructor:

AssocArray<double, string> myAssocArray(names, myArr);

the code for the constructor:

template <class V, class AI, class I, class S>
AssocArray<V, AI, I, S>::AssocArray(const list<AI>& names, const Array<V, I, S>& source)

I curr = source.MinIndex();

typename list<AI>::const_iterator it;
for (it = names.begin(); it != names.end(); it++)
internal_array.insert(pair<AI,I>(*it, source[curr]));



The warning that I get:

[Warning] passing `const double' for converting 2 of `std::pair<_T1, _T2>::pair(const _T1&, const _T2&) [with _T1 = std::string, _T2 = int]'

I would appreciate any insights.
Jul 5 '07 #1
Share this Question
Share on Google+
2 Replies

Expert Mod 5K+
P: 9,197
You need a pair with a const double:

Expand|Select|Wrap|Line Numbers
  1. pair<int, const double> obj;
None of your pair types are const.

Expand|Select|Wrap|Line Numbers
  1. internal_array.insert(pair<AI,const I>(*it, source[curr]));
Assuming l is a double.
Jul 6 '07 #2

P: 71
OK, thanks. Somehow once I restarted the compiler I stopped getting the errors.
Jul 6 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.