LukasScheucher / include-what-you-use

Automatically exported from code.google.com/p/include-what-you-use
Other
0 stars 0 forks source link

IWYU recommends to include <iterator> for some STL containers #148

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Steps to reproduce:
1. Try to use some containers' iterators.  For example, std::deque, std::set.

Actual result:
IWYU recommends to add #include <iterator>.

Expected result:
If we use only container, and container-defined iterators like 
std::set<int>::iterator, we shouldn't include <iterator>.

Discussion:
I've attached updated iterator.cc - with more containers.  It's not a final 
version, it contains a lot of debug stuff like #if 0...#endif.  There are no 
tests for stack and queue because they don't have iterators.  There are no 
tests for std::multimap, std::multiset because they are the same as std::map 
and std::set respectively.  std::string doesn't cause problems, added for 
completeness.  Not sure if std::initializer_list should be used as in the test, 
maybe will remove it in the future.  Also <regex> uses iterators, but it's not 
a container, so I haven't included it in iterator.cc.

Original issue reported on code.google.com by vsap...@gmail.com on 12 Jun 2014 at 7:28

Attachments:

GoogleCodeExporter commented 8 years ago
One approach is to fix the problem like issue #147 - by handling each iterator 
as a special case.  But at first I want to try to remap types like 
"std::__tree_iterator<int>" to "std::set<int>::iterator" automatically.  For 
instance, I can start by looking through typedefs.

Original comment by vsap...@gmail.com on 12 Jun 2014 at 7:32