Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ TheIDE » U++ TheIDE: Compiling, Linking, Debugging of your packages » Upp::Sort(begin, end, less) does not compile under MSC8 when less is a plain C function
Upp::Sort(begin, end, less) does not compile under MSC8 when less is a plain C function [message #29372] Sat, 16 October 2010 12:35 Go to previous message
Didier is currently offline  Didier
Messages: 680
Registered: November 2008
Location: France
Contributor
Hi all,

I stumbled accross an unexpected compile error that appears only when compiling with MSC8: no problem with GCC.

There is an easy workaround using a functor instead of a plain C compare function.

Is it an MSC8 limitation or a GCC added feature ?!?


Here is a sample code:
#include <Core/Core.h>

using namespace Upp;

typedef Pointf  XY;


bool CompareXY_x(XY a, XY b)
{
	return (a.x < b.x);
}


struct MyLessFunctor {
	bool operator () (const XY& a, const XY& b) const
	{
		return CompareXY_x(a, b);
	}
};

CONSOLE_APP_MAIN
{
	typedef Vector<XY> PointsType;
	
	
	PointsType points;
	
	points << XY(1,2) << XY(2,2) << XY(3,2) << XY(4,2) << XY(6,2);

	Sort(points, CompareXY_x); // Compile on GCC only
	Sort(points, MyLessFunctor() );// compiles on GCC and MSC8
}

[Updated on: Sat, 16 October 2010 12:37]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Exported makefiles don't treat WIN32 flag correctly
Next Topic: Version Tab in .exe properties
Goto Forum:
  


Current Time: Fri Apr 26 09:00:23 CEST 2024

Total time taken to generate the page: 0.03008 seconds