Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ > Re: question on...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 4 of 10 Topic 45739 of 47017
Post > Topic >>

Re: question on map< list<T>::iterator, int>

by Pete Becker <pete@[EMAIL PROTECTED] > May 3, 2008 at 10:08 AM

On 2008-05-03 08:48:01 -0400, "subramanian100in@[EMAIL PROTECTED]
 India" 
<subramanian100in@[EMAIL PROTECTED]
> said:

> 
> This program compiles fine with the command
> g++ -std=c++98 -pedantic -Wall -Wextra  x.cpp
> 
> However if I remove the comment, I get compilation error because
> operator '<' is not defined for list<T>::iterator. Why doesn't the
> compiler give this error for
> 'map<list<int>::iterator, int> m;' itself. That is, in this first
> statement inside main() itself, the compiler can know that the less-
> than operator cannot be defined for the key type. So, why does the
> compiler wait for an element to be pushed on to the map to flag the
> error ?
> 

The compiler doesn't compile template code that isn't used, so it 
doesn't notice the missing operator< until it's used.

-- 
  Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of "The 
Standard C++ Library Extensions: a Tutorial and Reference 
(www.petebecker.com/tr1book)
 




 10 Posts in Topic:
question on map< list::iterator, int>
"subramanian100in@[E  2008-05-03 05:48:01 
Re: question on map< list::iterator, int>
=?utf-8?Q?David_C=C3=B4me  2008-05-03 15:06:58 
Re: question on map< list::iterator, int>
Paul Brettschneider <p  2008-05-03 15:21:01 
Re: question on map< list::iterator, int>
Pete Becker <pete@[EMA  2008-05-03 10:08:27 
Re: question on map< list::iterator, int>
andrew.smith.cpp@[EMAIL P  2008-05-03 22:43:55 
Re: question on map< list::iterator, int>
Ian Collins <ian-news@  2008-05-04 17:57:05 
Re: question on map< list::iterator, int>
=?UTF-8?B?RXJpayBXaWtzdHL  2008-05-04 09:07:24 
Re: question on map< list::iterator, int>
andrew.smith.cpp@[EMAIL P  2008-05-04 21:42:27 
Re: question on map< list::iterator, int>
James Kanze <james.kan  2008-05-05 06:03:42 
Re: question on map< list::iterator, int>
James Kanze <james.kan  2008-05-05 06:12:48 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 15:54:11 CDT 2008.