🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Ann Kim Wed, 02 Aug 1995 02:55
OSpace STL<Toolkit> sort with non-builtins
#1539
Author: Ann Kim
Date: Wed, 02 Aug 1995 02:55
80 lines
2678 bytes
Hi

Sorry, if this isn't the right place to post (I've also posted
to comp.lamg.c++) but I've seen a few STL-related questions here
so ....


We are using STL<Toolkit> from ObjectSpace with MSVC2.1 on WinNT3.5.
When I tried to use the sort algorithm with a user-defined type the
compiler behaved strangely!

The following code in a .cpp file causes the compiler to give the error,

G:\tools\ospace\ospace/stl/advalgo.cpp(1477) : error C2227: 
left of '->__dtor' must point to class/struct/union


#include <stl.h>

class Foo
{
public:
	Foo() {};
	Foo(int i) {m_Foo = i;}	

	~Foo() {};

   	const Foo& operator=(const Foo& f) {m_Foo = f.m_Foo; return *this;}

	int m_Foo; 
	
};

bool operator>(const Foo &f1, const Foo & other)  {return f1.m_Foo > other.m_Foo;}
bool operator<(const Foo & f1, const Foo & other) {return f1.m_Foo < other.m_Foo;}
bool operator==(const Foo & f1, const Foo & other) {return f1.m_Foo == other.m_Foo;}


void
main()
{
 	vector<Foo> v;
	
	v.push_back(6);
	v.push_back(1);	
	v.push_back(4);	
		
	sort(v.begin(), v.end());
	
}


Commenting out the destructor makes this error go away (and the code to work).
Substituting trivial class Foo usage with another (less trivial) class which
doesn't have a destructor explicity declared/defined still causes the same
error to occur. Substituting with class string (implemented here but
essentially the Plauger "standard string" class) works fine! (string has
a destructor).

Initially we thought the problem could be related to the fact that class Foo
had a destructor. Classes string and another class which both have destructors
confirm that this behaviour is not consistent.

Has anyone had similar experiences and/or can shed some light? (PLEASE?)

	Thanks in advance.
		
		Ann

------------------------------------------------------------------------
Ann Kim					The Chifley Tower
Analyst/Programmer			2 Chifley Square
Derivatives Technology			Sydney 2000 NSW Australia
Bankers Trust Australia Limited		ph:  +612 2599378
					fax: +612 2599486
e-mail:  annkim@magna.com.au

"Les opinions exprimees ici me sont personnelles et n engagent
pas le BT Australia Limited."
------------------------------------------------------------------------
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads