Boost logo

Boost :

From: Darin Adler (darin_at_[hidden])
Date: 1999-09-19 18:30:39


In case my other message is two long, here are abbreviated comments and
suggestions that cover most of what I said in that message and one or two
other things. Read the longer message for the rationale, examples, and
arguments in favor of some of these these changes. I don't think these
depend on each other; each should stand on its own.

    - polymorphic_downcast<> is poor name because it's for upcasts too
    + change name to polymorphic_static_cast<>

    - polymorphic_downcast allows incorrect casts that arise in presence of
multiple inheritance
    + change implementation to use stronger assert

    - some users of casts.hpp may prefer asserts instead of exceptions
    + make version of casts.hpp that can do asserts instead of exceptions
(use two different namespaces and determine which to import into boost with
a compile-time switch; exception version should be default)

    - check of number range can be factored out of numeric_cast<>
    + factor into a separate inline function template, number_in_range<>

    - implicit_cast quiets "implicit numeric conversion" warnings
    + leave these warnings on for implicit_cast<>; use numeric_cast<> to
quiet the warnings

    - want cast that works like static_cast<>, but only on numbers; can't
use numeric_cast<> because it only works in cases where value is preserved
    + add cast like static_cast<> that works only on numbers; suggested
name: numeric_static_cast<>

    - want cast that works like static_cast<>, but only for casting from
void* since that's a common reason to use it
    + add cast like static_cast that works only on (potentially
cv-qualified) void*; suggested name: void_pointer_cast

Once these casts are used, a search for static_cast and reinterpret_cast in
a program should find only questionable casts. Typical uses will use the
boost casts, const_cast, or dynamic_cast instead.

    -- Darin


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