Boost logo

Boost :

From: Jeffrey C. Jacobs (darklord_at_[hidden])
Date: 2002-09-10 15:35:34


Hello!

I have written a proposal for the boost community (a small one that will
help me with other proposals on which I am working) and was wondering even
if this does not become a part of boost (though I would like you to consider
it) maybe some of you would be willing to help me answer some of the
"Unanswered Questions".

I have therefore included my comments from the header and have made the
actual file available at:

http://groups.yahoo.com/group/boost/files/TimeHorse/sign_traits.hpp

Though I will be moving it to www.timehorse.com hopefully later this week.
I also have a small test script that I will make available later.

Anyway, here are my comments on the design:

// Template class sign_traits<Integral> --
//
// Supplies:
//
// typedef integer_type -- same type as Integral
// typedef signed_type -- the equivalent of "signed Integral"
// typedef unsigned_type -- the equivalent of "unsigned Integral"
//
// Unanswered Questions:
//
// 1. The non-specialized form of sign_traits should not compile
because
// signed and unsigned cannot be applied to class type. Then again, if
// Integral is not Integral then it can't have a signed and unsigned
type.
// OTTH, if you COULD so that when "typename Integral" is "int" we
write
// "unsigned Integral" for instance, I wouldn't need sign_traits! :)
//
// 2. Consider floating types, e.g. signed_type is implied but
// unsigned type does not exist. Therefore, can unsigned_type be
// effectively "void"?
//
// 3. Should "integer_type" be simply "type" for consistancy?
//
// 4. cv-qualified forms not supplied
//
// 5. Assuming int, short and long are all signed IIRC the spec
demands.
//
// 6. When BOOST_NO_INTRINSIC_WCHAR_T is undefined, assumes
// "signed wchar_t" is valid.
//
// Template function signed_cast<cv-unqualified Integral>
//
// Parameters:
//
// cv-qualified Integral _T -- type to be converted
// OR
// cv-qualified Integral &_T -- reference to type to be converted
//
// Returns:
//
// cv-qualified signed Integral -- if _T is pass by value
// OR
// cv-qualified signed Integral & -- if _T is pass by reference.
//
// Template function unsigned_cast<cv-unqualified Integral>
//
// Parameters:
//
// cv-qualified Integral _T -- type to be converted
// OR
// cv-qualified Integral &_T -- reference to type to be converted
//
// Returns:
//
// cv-qualified unsigned Integral -- if _T is pass by value
// OR
// cv-qualified unsigned Integral & -- if _T is pass by reference.
//
// Unanswered Questions:
//
// 1. Assumes that cv-qualification count in function overloading
// though MSVC 6.0 reports the const and volatile forms of these
// functions as redefinitions of the cv-unqualified form (C2373).
//
// 2. Should the cast functions be implemented as structs optionally
// with helper functions? Used function because of type deduction
// but then it is potentially dissimilar from *_cast in standard
// since the out-type is implied from the in-type and likewise
// in-type must be [cv-unqualified] "typename Integral" type
//
// 3. Implemented in terms of static_cast; is that wise?
//
// 4. cv-qualified sign_triats may eliminate cv-qualified functions??
//
// 5. Both pass-by-value (for immediates) and pass-by-reference
// (for class-type Integrals that specialize sign_traits) but is
// the later unnecessary since we may make such concept invalid,
// and are variables of Intergal types then passed by reference
// unnecessiarily?
//
// Other questions:
//
// 1. Should I be #including any other boost libraries?
//
// 2. Should this be a part of numberic_traits??
//
// 3. Could someone please correct my spelling??
//

Jeffrey.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk