VC ++ 11 and multidimensional iterators (overload) C2535

I just play with the new VS 2012, and I have a problem, probably with the new C ++ 11. This code code works fine when I install the platform toolkit for VS2010 (v100) in the project settings.

.h:

typedef std::multimap<unsigned, unsigned> SizeMap; typedef std::map<unsigned, unsigned> OffsetMap; private: inline void _RemoveBlockL(SizeMap::iterator sizeI); inline void _RemoveBlockL(OffsetMap::iterator offsetI); 

.cpp

 inline void Foo::_RemoveBlockL(SizeMap::iterator sizeI) { // impementation } inline void Foo::_RemoveBlockL(OffsetMap::iterator offsetI) { // impementation } 

But when I change this for VS2012 (v110), I will get the following error:

 Error 61 error C2535: 'void Boo::system::Foo::_RemoveBlockL(std::_Tree_iterator<_Mytree>)' : member function already defined or declared D:\_work\wp-test\boo\system\foo.h 

Why does overload not work in VC ++ 11?

+4
source share
2 answers

Two possibilities that I can think of are that, since _RemoveBlockL reserved for the compiler, something has changed and is now reserved, or that in the new compiler, two iterators actually have the same type. Do you really need different functional behavior depending on whether it is map or multimap ?

Assuming what you are doing (due to typedef names), the correct solution is simply not to use overloading to solve this problem. Give the names of functions that represent what they actually do (or, alternatively, you can use strong_typedef to create a strong alias so that you can overload, but I can't imagine a complete solution).

+1
source

This is just an opportunity, at the moment I can’t check, but they changed the way iterators are used in vC ++ 11, so they can be the same basic type, which makes overloading impossible.

Do iterators of different types of containers require different types?

See http://blogs.msdn.com/b/vcblog/archive/2012/04/06/10291485.aspx

+5
source

Source: https://habr.com/ru/post/1432738/


All Articles