Boost logo

Boost :

From: Peder Holt (peder.holt_at_[hidden])
Date: 2004-12-07 02:35:16


...
Turns out that the problem can be solved rather elegantly (for VC6.5, anyway :)
The following code compiles in VC 6.5 :

#pragma warning (disable:4786)
#include <map>
#include <list>

template<typename A0,typename A1>
void deduce_container(std::list<A0,A1>::iterator)
{
   int b=0;
}

template<typename A0,typename A1,typename A2,typename A3,typename A4>
void deduce_container(std::_Tree<A0, A1, A2, A3, A4>::iterator)
{
   int b=0;
}

void main() {
   std::map<int,double>::iterator a;
   std::list<int*>::iterator b;
   deduce_container(a);
   deduce_container(b);
}
(Note that std::set<A0,A1,A2>::iterator is a typedef, and can not be
deduced. std::_Tree<...>::iterator is an nested class, and can be
deduced)

I don't know if this is legal for other compilers, but if it is, we
should define a new macro:
REGISTER_NESTED_TEMPLATE_CLASS(std::list,2,iterator)

It would then be possible to solve the stl problem outside the typeof
library, in e.g. the stl/register.hpp (With separate registrations for
the different stl-implementations, of course)

Peder


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk