🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1539

OSpace STL<Toolkit> sort with non-builtins

#1539
From: 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."
------------------------------------------------------------------------
Technical Details
Message-ID: <annkim.807332031@news.magna.com.au>
Path: arc1-ca.pugleaf.net!news.magna.com.au!annkim

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!news.magna.com.au!annkim
From: annkim@juicer.magna.com.au (Ann Kim)
Newsgroups: comp.std.c++
Subject: OSpace STL<Toolkit> sort with non-builtins
Date: 2 Aug 1995 12:55:30 +1000
Organization: A poorly-installed InterNetNews site
Message-ID: <annkim.807332031@news.magna.com.au>
NNTP-Posting-Host: magna.com.au
Keywords: STL sort
X-Newsreader: NN version 6.5.0 #4 (NOV)