This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
namespace error???
- To: egcs-bugs at egcs dot cygnus dot com
- Subject: namespace error???
- From: gustavo <gustavo at geneura dot ugr dot es>
- Date: Wed, 26 Apr 2000 19:55:17 +0200
Hi all:
When compiling a little program a problem arises if I call a namespace
with a name different from std. With std it works fine!
compiler version is
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
Thanks ins advance
Gustavo
//-----------------------------------------------------------------------------
// bug.cc --> using namespace std works but noother else :(
//-----------------------------------------------------------------------------
#include <iostream> // ostream
#include <algorithm> // min/max_element
#include <vector> // vector
#include <list> // list
//-----------------------------------------------------------------------------
namespace eo
{
template<class Container> class Pop: public Container
{
public:
typedef typename Container::value_type chromosome;
Pop(unsigned num = 0): Container(num) {}
friend ostream& operator<<(ostream& os, const Pop<Container>& pop)
{
copy(pop.begin(), pop.end(), ostream_iterator<chromosome>(os, " "));
return os;
}
};
} // namespace std
//-----------------------------------------------------------------------------
typedef eo::Pop<vector<int> > vPop;
typedef eo::Pop<list<int> > lPop;
//-----------------------------------------------------------------------------
main()
{
vPop v(5);
lPop l(5);
cout << "sizeof(Pop<vector<int> >) = " << sizeof(v) << endl
<< "sizeof(Pop<list<int> >) = " << sizeof(l) << endl;
cout << "v:" << endl << v << endl
<< "l:" << endl << l << endl;
}
//-----------------------------------------------------------------------------