Mail Archives: djgpp/2002/08/13/10:51:17
"André Pönitz" <poenitz AT gmx DOT de> wrote in message news:ajafb5$gv6$8 AT narses DOT hrz DOT tu-chemnitz DOT de...
> Alex Vinokur <alexvn AT bigfoot DOT com> wrote:
> > It seems that using template with typedef below causes warnings.
> > typedef map<AAA, vector<BBB<int> >, less<AAA> > map1_typename; // No problem with gcc-3.1
>
> > typedef map1_typename::value_type map1_value_type;
>
> Have you tried:
>
> typedef typename map1_typename::value_type map1_value_type;
>
> ^^^^^^^^
>
> here? As silly as it looks, the Standard requires this even if there is
> no ambiguity...
>
> Andre'
>
> --
> Those who desire to give up Freedom in order to gain Security,
> will not have, nor do they deserve, either one. (T. Jefferson)
Andre', thank you.
It helped me.
============
Windows 2000
DJGPP 2.03
gcc/gpp 3.1
============
A code below has no problem with gcc/gpp 3.1
######### C++ code : BEGIN #########
#include <vector>
#include <map>
using namespace std;
// --------------
class AAA {};
bool operator< (const AAA& ins1, const AAA& ins2)
{
return true;
}
// --------------
template <typename T1>
class BBB {};
// --------------
template <typename T1>
void foo1 ()
{
typedef map<AAA, vector<BBB<int> >, less<AAA> > map1_typename;
typedef map1_typename::value_type map1_value_type;
pair<map1_typename::iterator, bool> pair1_insert;
map1_typename::iterator map1_pos;
// No problem with gcc-3.1
typedef map<AAA, vector<BBB<T1> >, less<AAA> > map2_typename;
typedef typename map2_typename::value_type map2_value_type;
pair<typename map2_typename::iterator, bool> pair2_insert;
typename map2_typename::iterator map2_pos;
} // foo1
// --------------
int main ()
{
return 0;
}
######### C++ code : END ###########
Nevertheless, there is inequality of rights
between
typedef map<AAA, vector<BBB<int> >, less<AAA> > map1_typename;
and
typedef map<AAA, vector<BBB<T1> >, less<AAA> > map2_typename;
map1_typename does NOT require the 'template' word (because of BBB<int> ? )
map2_typename DOES require the 'template' word (because of BBB<T1> ? )
Any explanation ?
====================
Alex Vinokur
http://up.to/alexvn
http://go.to/alexv_math
mailto:alexvn AT bigfoot DOT com
mailto:alexvn AT go DOT to
====================
- Raw text -