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 » Moveable classes with virtual functions/Documentation error
Moveable classes with virtual functions/Documentation error [message #2527] Sun, 16 April 2006 23:05 Go to next message
hans is currently offline  hans
Messages: 44
Registered: March 2006
Location: Germany
Member
Hi,
documentation states in srcdoc/Core/Moveable:

All of the following requirements should be fullfilled for moveable types:
- It does not have any virtual method nor virtual base class.

This is imho incorrect, as U++ itself uses moveable classes with virtual methods, e.g. class Value.

Don't know what's the case with virtual base classes Razz
Re: Moveable classes with virtual functions/Documentation error [message #2551 is a reply to message #2527] Mon, 17 April 2006 19:03 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
hans wrote on Sun, 16 April 2006 17:05

Hi,
documentation states in srcdoc/Core/Moveable:

All of the following requirements should be fullfilled for moveable types:
- It does not have any virtual method nor virtual base class.

This is imho incorrect, as U++ itself uses moveable classes with virtual methods, e.g. class Value.

Don't know what's the case with virtual base classes Razz



First of all, no, Value does not have virtual methods (it stores a pointer to heap object with virtual methods, but that is something else).

Second, technically, it is true that there are no technical reasons for "normal" C++ implementation why polymorphic classes should not be moveable (while virtual base classes are not quite often AFAIK).

However, whole Moveable concept is walking on the thin ice. In practice, you really need just concrete types to be moveable; therefore virtual methods are not required. By excluding them, we might be makeing that ice little bit less thin, makeing "moveable" types closer to PODs, with no real disadvantage.

Mirek
Re: Moveable classes with virtual functions/Documentation error [message #2555 is a reply to message #2551] Mon, 17 April 2006 20:26 Go to previous message
hans is currently offline  hans
Messages: 44
Registered: March 2006
Location: Germany
Member
Yes, you are right. Virtual methods are in embedded class Void inside Value, so no problem for Value.

But imho the restriction in practice is too restrictive, as all implementations I know off are storing a vptr (ptr to virtual methods table), so moveable should not be a problem.

I agree that in practice most of the time only concrecte
types need to be moveable, so playing safe is probably better.

Previous Topic: Value class suggestion [FEATURE REQUEST]
Next Topic: NFormat should check if args were left
Goto Forum:
  


Current Time: Sat Apr 27 07:54:23 CEST 2024

Total time taken to generate the page: 0.08955 seconds