[prev in list] [next in list] [prev in thread] [next in thread]
List: gcc
Subject: Bug in egcs-2.91.60
From: Carlo Wood <carlo () runaway ! xs4all ! nl>
Date: 1999-04-19 14:11:58
[Download RAW message or body]
Hi,
the following piece of code should compile imho.
I tested it on another OS (Using `CC' on IRIX) and there it compiles.
(It won't link due to a missing operator!=, but that is not the point).
With egcs-1.1 I get:
ios_tst.cc: In function `typename TYPE::manip_data_ct * get_manip_data(class ostream &, const TYPE &)':
ios_tst.cc:20: parse error before `::'
ios_tst.cc:23: parse error before `::'
ios_tst.cc:26: parse error before `::'
ios_tst.cc:28: confused by earlier errors, bailing out
--
Carlo Wood <carlo@runaway.xs4all.nl>
-ios_tst.cc:---------------------------------------------------------------
#include <iostream.h>
#include <iomanip.h>
#include <vector.h>
#include <algo.h>
template<class MANIP_DATA>
class manip_id_tct {
public:
typedef vector<MANIP_DATA *> ids_ct;
static ids_ct ids;
};
template<class MANIP_DATA>
typename manip_id_tct<MANIP_DATA>::ids_ct manip_id_tct<MANIP_DATA>::ids;
template<class TYPE>
inline typename TYPE::manip_data_ct *get_manip_data(ostream &os, TYPE const&)
{
typename TYPE::manip_data_ct::ids_ct::iterator i;
i = find(TYPE::manip_data_ct::ids.begin(),
TYPE::manip_data_ct::ids.end(),
os.rdbuf());
if (i != TYPE::manip_data_ct::ids.end())
return *i;
typename TYPE::manip_data_ct *md = new typename TYPE::manip_data_ct;
TYPE::manip_data_ct::ids.push_back(md);
return md;
}
// Start foo test:
class foo_md_ct : public manip_id_tct<foo_md_ct> { // Mandatory inheritance
int w;
public:
foo_md_ct(void) : w(5) { }
int get_w(void) const { return w; }
};
class foo {
typedef foo_md_ct manip_data_ct; // Mandatory typedef
int i;
public:
foo(void) : i(123) { }
friend ostream &operator<<(ostream &os, const foo &f);
};
ostream &operator<<(ostream &os, const foo &f)
{
foo::manip_data_ct *m = get_manip_data(os, f); // Mandatory line
os << setw(m->get_w()) << f.i;
return os;
}
int main(void)
{
foo f;
cout << f << endl;
return 0;
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic