Boost logo

Boost :

From: Gennaro Prota (gennaro_prota_at_[hidden])
Date: 2003-01-14 14:54:23


I was running some tests on the max_of, min_of etc. templates I've
proposed some days ago and, *as expected*, VC++ gave problems with
integral conversions of enumerators. As I think you all know, if you
have something like

    enum e { e1 = 1u << 31 };

then it simply "promotes" e1 to int instead of unsigned int. For
instance this

    enum e { e1 = 2147483648u };

    #include <iostream>

    int main() {
        std::cout << e1 << '\n';
    }

outputs -2147483648. Applied to my code, where I have e.g.

    template<>
    struct max_of<unsigned int> {
        BOOST_STATIC_CONSTANT( promoted_of<unsigned int>::type,
                               value = UINT_MAX
                             );

    };

this means that max_of<unsigned int>::value, and of course
max_of<unsigned long>::value, will simply be converted to -1. Before
inventing my own solution, has boost already a workaround or a
convention for this problem?

Thanks,
Genny.


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