annotate DEPENDENCIES/generic/include/boost/serialization/static_warning.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents c530137014c0
children
rev   line source
Chris@16 1 #ifndef BOOST_SERIALIZATION_STATIC_WARNING_HPP
Chris@16 2 #define BOOST_SERIALIZATION_STATIC_WARNING_HPP
Chris@16 3
Chris@16 4 // (C) Copyright Robert Ramey 2003. Jonathan Turkanis 2004.
Chris@16 5 // Use, modification and distribution is subject to the Boost Software
Chris@16 6 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 7 // MS compatible compilers support #pragma once
Chris@101 8 #if defined(_MSC_VER)
Chris@16 9 # pragma once
Chris@16 10 #endif
Chris@16 11
Chris@16 12 // http://www.boost.org/LICENSE_1_0.txt)
Chris@16 13
Chris@16 14 // See http://www.boost.org/libs/static_assert for documentation.
Chris@16 15
Chris@16 16 /*
Chris@16 17 Revision history:
Chris@16 18 15 June 2003 - Initial version.
Chris@16 19 31 March 2004 - improved diagnostic messages and portability
Chris@16 20 (Jonathan Turkanis)
Chris@16 21 03 April 2004 - works on VC6 at class and namespace scope
Chris@16 22 - ported to DigitalMars
Chris@16 23 - static warnings disabled by default; when enabled,
Chris@16 24 uses pragmas to enable required compiler warnings
Chris@16 25 on MSVC, Intel, Metrowerks and Borland 5.x.
Chris@16 26 (Jonathan Turkanis)
Chris@16 27 30 May 2004 - tweaked for msvc 7.1 and gcc 3.3
Chris@16 28 - static warnings ENabled by default; when enabled,
Chris@16 29 (Robert Ramey)
Chris@16 30 */
Chris@16 31
Chris@16 32 #include <boost/config.hpp>
Chris@16 33
Chris@16 34 //
Chris@16 35 // Implementation
Chris@16 36 // Makes use of the following warnings:
Chris@16 37 // 1. GCC prior to 3.3: division by zero.
Chris@16 38 // 2. BCC 6.0 preview: unreferenced local variable.
Chris@16 39 // 3. DigitalMars: returning address of local automatic variable.
Chris@16 40 // 4. VC6: class previously seen as struct (as in 'boost/mpl/print.hpp')
Chris@16 41 // 5. All others: deletion of pointer to incomplete type.
Chris@16 42 //
Chris@16 43 // The trick is to find code which produces warnings containing the name of
Chris@16 44 // a structure or variable. Details, with same numbering as above:
Chris@16 45 // 1. static_warning_impl<B>::value is zero iff B is false, so diving an int
Chris@16 46 // by this value generates a warning iff B is false.
Chris@16 47 // 2. static_warning_impl<B>::type has a constructor iff B is true, so an
Chris@16 48 // unreferenced variable of this type generates a warning iff B is false.
Chris@16 49 // 3. static_warning_impl<B>::type overloads operator& to return a dynamically
Chris@16 50 // allocated int pointer only is B is true, so returning the address of an
Chris@16 51 // automatic variable of this type generates a warning iff B is fasle.
Chris@16 52 // 4. static_warning_impl<B>::STATIC_WARNING is decalred as a struct iff B is
Chris@16 53 // false.
Chris@16 54 // 5. static_warning_impl<B>::type is incomplete iff B is false, so deleting a
Chris@16 55 // pointer to this type generates a warning iff B is false.
Chris@16 56 //
Chris@16 57
Chris@16 58 //------------------Enable selected warnings----------------------------------//
Chris@16 59
Chris@16 60 // Enable the warnings relied on by BOOST_STATIC_WARNING, where possible. The
Chris@16 61 // only pragma which is absolutely necessary here is for Borland 5.x, since
Chris@16 62 // W8073 is disabled by default. If enabling selected warnings is considered
Chris@16 63 // unacceptable, this section can be replaced with:
Chris@16 64 // #if defined(__BORLANDC__) && (__BORLANDC__ <= 0x600)
Chris@16 65 // pragma warn +st
Chris@16 66 // #endif
Chris@16 67
Chris@16 68 // 6. replaced implementation with one which depends solely on
Chris@16 69 // mpl::print<>. The previous one was found to fail for functions
Chris@16 70 // under recent versions of gcc and intel compilers - Robert Ramey
Chris@16 71
Chris@16 72 #include <boost/mpl/bool.hpp>
Chris@16 73 #include <boost/mpl/print.hpp>
Chris@16 74 #include <boost/mpl/eval_if.hpp>
Chris@101 75 #include <boost/static_assert.hpp>
Chris@16 76
Chris@16 77 namespace boost {
Chris@16 78 namespace serialization {
Chris@16 79
Chris@16 80 template<int L>
Chris@16 81 struct BOOST_SERIALIZATION_STATIC_WARNING_LINE{};
Chris@16 82
Chris@16 83 template<bool B, int L>
Chris@16 84 struct static_warning_test{
Chris@16 85 typename boost::mpl::eval_if_c<
Chris@16 86 B,
Chris@16 87 boost::mpl::true_,
Chris@16 88 typename boost::mpl::identity<
Chris@16 89 boost::mpl::print<
Chris@16 90 BOOST_SERIALIZATION_STATIC_WARNING_LINE<L>
Chris@16 91 >
Chris@16 92 >
Chris@16 93 >::type type;
Chris@16 94 };
Chris@16 95
Chris@16 96 template<int i>
Chris@16 97 struct BOOST_SERIALIZATION_SS {};
Chris@16 98
Chris@16 99 } // serialization
Chris@16 100 } // boost
Chris@16 101
Chris@16 102 #define BOOST_SERIALIZATION_BSW(B, L) \
Chris@16 103 typedef boost::serialization::BOOST_SERIALIZATION_SS< \
Chris@16 104 sizeof( boost::serialization::static_warning_test< B, L > ) \
Chris@101 105 > BOOST_JOIN(STATIC_WARNING_LINE, L) BOOST_STATIC_ASSERT_UNUSED_ATTRIBUTE;
Chris@16 106 #define BOOST_STATIC_WARNING(B) BOOST_SERIALIZATION_BSW(B, __LINE__)
Chris@16 107
Chris@16 108 #endif // BOOST_SERIALIZATION_STATIC_WARNING_HPP