#622 Semantics of Conversion
Metadata
Property | Value |
---|---|
Reported by | Martin Nolte (nolte@mathematik.uni-freiburg.de) |
Reported at | Oct 6, 2009 16:01 |
Type | Unknown |
Version | Git (pre2.4) [autotools] |
Operating System | Unspecified / All |
Last edited by | Andreas Dedner (A.S.Dedner@warwick.ac.uk) |
Last edited at | Aug 25, 2012 09:49 |
Closed by | Andreas Dedner (A.S.Dedner@warwick.ac.uk) |
Closed at | Aug 25, 2012 09:49 |
Closed in version | Unknown |
Resolution | Works for me |
Comment | If there still is some problem then please reopen |
Description
What is the exact semantics of Conversion< From, To > in typetraits.hh?
Problem: In the current implementation, class From needs a copy constructor (unless From = To) and hence may not be pure virtual.
Possible semantics:
- Conversion::exists == true, iff a static_cast will succeed
- Conversion::exists == true, iff To is a base class of From
ad 1) In this case, the constructor From( const To & ), but the check should not fail if it does not exist. In the current implementation From also needs a copy constructor (which could be fixed by 'static From &makeFrom()'). Moreover, the specialization of Conversion< T, T > is wrong, since it returns true, even if the copy constructor is private.
ad 2) In this case, the copy constructors need not exist and we really should check if a reference can be converted, i.e., 'static Small test( To & )' and 'static From &makeFrom()'.
P.S.: In both suggested fixes, we need to assure that From and To respectively are no reference types.