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++ Library support » U++ Core » MSC problems: pick_ != const
Re: MSC problems: pick_ != const [message #20932 is a reply to message #20931] Mon, 20 April 2009 00:25 Go to previous messageGo to previous message
mirek is currently offline  mirek
Messages: 14267
Registered: November 2005
Ultimate Member
Mindtraveller wrote on Sun, 19 April 2009 17:07

For example, this code causes error:
struct AOp : Moveable<AOp>
{
	One<AOpHardware> hardware;
};

class AOps : public Vector<AOp>
{
public:
	void Xmlize(XmlIO xml) {XmlizeContainer(xml, "aop", *this);}
};

This is caused by the fact that pick != const in MSC compiler. And somewhere within U++ Core we have copying of Vector member with const argument (not pick_!):
//Core/Topt.h @ 135
template <class T>
inline void DeepCopyConstruct(void *p, const T& x) {
	::new(p) T(x);
}

This is strange. Class One supports pick behaviour, so accroding to U++ principles this code should compile without errors.
Am I right?


Yes and no.

pick definitely is not equal to semantics of const. (const guarantees no change).

That, after all, is why there is #define pick_...

Anyway, we are sort of at odds with C++ standard here as we would like to have pick_ constructors used when returning containers from functions. According to C++ standard, this is only possible if they are const (the critical rule is "nonconst references cannot be bound to temporaries").

Surprisingly, MSC++ has relaxed rules (you can call it a bug) w.r.t. to this, probably because some old MFC code was breaking the rule too. As we know when we are compiling with MSC, I decided make #define pick_ empty in that case; it better matches wanted pick_ semantics and is able to catch a bug here are there, like if you are trying to use DeepCopyConstruct on pick type.

Mirek
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: [REQUEST] IsHidden for POSIX platforms
Next Topic: Add the replace string with wildcards from editor to core
Goto Forum:
  


Current Time: Sun Aug 24 15:11:15 CEST 2025

Total time taken to generate the page: 0.05856 seconds