|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2003-09-06 19:05:00
Robert Ramey <ramey_at_[hidden]> writes:
> Finally, BOOST_STATIC_WARNING should be considered.
> This turns out to be highly compiler dependent but worth
> the effort in my opinion. I made for msvc but the version
> doesn't work with gcc. In my opinion this is very doable
> and very useful as well.
We were going to roll the following into MPL; instantiating print<T>
produces a warning message containing T on most compilers.
--- // boost/mpl/print.hpp -- Copyright 2003 Dave Abrahams #include <boost/config.hpp> #include <boost/mpl/int.hpp> #include <boost/mpl/range_c.hpp> #include <boost/mpl/plus.hpp> #include <boost/mpl/fold.hpp> #include <boost/mpl/identity.hpp> namespace boost { namespace mpl { #if BOOST_MSVC # pragma warning(push, 3) // we only want one warning from MSVC, so turn off the other one # pragma warning(disable: 4307) #elif __MWERKS__ # pragma warn_hidevirtual on #endif #if __EDG_VERSION__ template <class T> struct dependent_unsigned { static const unsigned value = 1; }; #endif struct fu { virtual void f() {} }; template <class T> struct incomplete; template <class T> struct print : mpl::identity<T> #if __MWERKS__ , fu #endif { #if BOOST_MSVC enum { n = sizeof(T) + -1 }; #elif __MWERKS__ void f(int); #else enum { n = # if __EDG_VERSION__ dependent_unsigned<T>::value # else sizeof(T) # endif > -1, }; #endif }; }} #if BOOST_MSVC # pragma warning(pop) #elif __MWERKS__ # pragma warn_hidevirtual reset #endif -- Dave Abrahams Boost Consulting www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk