diff --git a/include/boost/type_traits/alignment_of.hpp b/include/boost/type_traits/alignment_of.hpp index 83ae20b..a4a5b95 100644 --- a/include/boost/type_traits/alignment_of.hpp +++ b/include/boost/type_traits/alignment_of.hpp @@ -18,6 +18,9 @@ # pragma warning(push) # pragma warning(disable: 4121) // alignment is sensitive to packing #endif +#ifdef __BORLANDC__ +#pragma option push -Vx- -Ve- +#endif namespace boost { @@ -65,6 +68,13 @@ struct alignment_of { }; #endif +#ifdef __BORLANDC__ +// long double gives an incorrect value of 10 (!) +// unless we do this... +struct long_double_wrapper{ long double ld; }; +template<> struct alignment_of + : public alignment_of{}; +#endif // void has to be treated specially: BOOST_TT_AUX_SIZE_T_TRAIT_SPEC1(alignment_of,void,0) @@ -76,6 +86,9 @@ BOOST_TT_AUX_SIZE_T_TRAIT_SPEC1(alignment_of,void const volatile,0) } // namespace boost +#ifdef __BORLANDC__ +#pragma option pop +#endif #ifdef BOOST_MSVC # pragma warning(pop) #endif @@ -83,3 +96,4 @@ BOOST_TT_AUX_SIZE_T_TRAIT_SPEC1(alignment_of,void const volatile,0) #include "boost/type_traits/detail/size_t_trait_undef.hpp" #endif // BOOST_TT_ALIGNMENT_OF_HPP_INCLUDED + diff --git a/include/boost/type_traits/config.hpp b/include/boost/type_traits/config.hpp index 749b7d6..a2bf635 100644 --- a/include/boost/type_traits/config.hpp +++ b/include/boost/type_traits/config.hpp @@ -14,6 +14,17 @@ #include "boost/config.hpp" #endif +// +// whenever we have a conversion function with elipses +// it needs to be declared __cdecl to suppress compiler +// warnings from MS and Borland compilers (this *must* +// appear before we include is_same.hpp below): +#if defined(BOOST_MSVC) || defined(__BORLANDC__) +# define BOOST_TT_DECL __cdecl +#else +# define BOOST_TT_DECL /**/ +#endif + // // Helper macros for builtin compiler support. // If your compiler has builtin support for any of the following @@ -77,18 +88,9 @@ # define BOOST_HAS_TRIVIAL_DESTRUCTOR(T) false #endif -// -// whenever we have a conversion function with elipses -// it needs to be declared __cdecl to suppress compiler -// warnings from MS and Borland compilers: -#if defined(BOOST_MSVC) || defined(__BORLANDC__) -# define BOOST_TT_DECL __cdecl -#else -# define BOOST_TT_DECL /**/ -#endif - # if (defined(__MWERKS__) && __MWERKS__ >= 0x3000) || BOOST_MSVC > 1301 || defined(BOOST_NO_COMPILER_CONFIG) # define BOOST_TT_HAS_CONFORMING_IS_CLASS_IMPLEMENTATION #endif #endif // BOOST_TT_CONFIG_HPP_INCLUDED + diff --git a/include/boost/type_traits/detail/bool_trait_def.hpp b/include/boost/type_traits/detail/bool_trait_def.hpp index f3f4f0a..e029e31 100644 --- a/include/boost/type_traits/detail/bool_trait_def.hpp +++ b/include/boost/type_traits/detail/bool_trait_def.hpp @@ -53,7 +53,7 @@ BOOST_TT_AUX_TEMPLATE_ARITY_SPEC(2,trait) \ /**/ #define BOOST_TT_AUX_BOOL_TRAIT_SPEC1(trait,sp,C) \ -template<> struct trait \ +template<> struct trait< sp > \ : mpl::bool_c< C > \ { \ BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ @@ -62,7 +62,7 @@ template<> struct trait \ /**/ #define BOOST_TT_AUX_BOOL_TRAIT_SPEC2(trait,sp1,sp2,C) \ -template<> struct trait \ +template<> struct trait< sp1,sp2 > \ : mpl::bool_c< C > \ { \ BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ @@ -71,7 +71,7 @@ template<> struct trait \ /**/ #define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(param,trait,sp,C) \ -template< param > struct trait \ +template< param > struct trait< sp > \ : mpl::bool_c< C > \ { \ BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ @@ -79,7 +79,7 @@ template< param > struct trait \ /**/ #define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(param1,param2,trait,sp,C) \ -template< param1, param2 > struct trait \ +template< param1, param2 > struct trait< sp > \ : mpl::bool_c< C > \ { \ BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ @@ -87,7 +87,7 @@ template< param1, param2 > struct trait \ /**/ #define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1(param,trait,sp1,sp2,C) \ -template< param > struct trait \ +template< param > struct trait< sp1,sp2 > \ : mpl::bool_c< C > \ { \ BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ @@ -96,7 +96,7 @@ template< param > struct trait \ /**/ #define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(param1,param2,trait,sp1,sp2,C) \ -template< param1, param2 > struct trait \ +template< param1, param2 > struct trait< sp1,sp2 > \ : mpl::bool_c< C > \ { \ BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \ diff --git a/include/boost/type_traits/is_const.hpp b/include/boost/type_traits/is_const.hpp index 34149dd..19b0a7f 100644 --- a/include/boost/type_traits/is_const.hpp +++ b/include/boost/type_traits/is_const.hpp @@ -15,6 +15,9 @@ #ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION # include "boost/type_traits/detail/cv_traits_impl.hpp" +# ifdef __GNUC__ +# include +# endif #else # include "boost/type_traits/is_reference.hpp" # include "boost/type_traits/is_array.hpp" @@ -43,6 +46,13 @@ BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T& volatile,false) BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T& const volatile,false) #endif +#ifdef __GNUC__ +// special case for gcc where illegally cv-qualified reference types can be +// generated in some corner cases: +BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T const,!(::boost::is_reference::value)) +BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T volatile const,!(::boost::is_reference::value)) +#endif + #else namespace detail { diff --git a/include/boost/type_traits/is_empty.hpp b/include/boost/type_traits/is_empty.hpp index 9c9191b..345a949 100644 --- a/include/boost/type_traits/is_empty.hpp +++ b/include/boost/type_traits/is_empty.hpp @@ -190,6 +190,14 @@ template struct is_empty_impl } // namespace detail BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_empty,T,::boost::detail::is_empty_impl::value) +// these help when the compiler has no partial specialization support: +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_empty,void,false) +#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_empty,void const,false) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_empty,void volatile,false) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_empty,void const volatile,false) +#endif + } // namespace boost diff --git a/include/boost/type_traits/is_enum.hpp b/include/boost/type_traits/is_enum.hpp index 172be3a..8102181 100644 --- a/include/boost/type_traits/is_enum.hpp +++ b/include/boost/type_traits/is_enum.hpp @@ -99,6 +99,13 @@ BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_enum,T,::boost::detail::is_enum_impl::value) BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_enum,float,false) BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_enum,double,false) BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_enum,long double,false) +// these help on compilers with no partial specialization support: +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_enum,void,false) +#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_enum,void const,false) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_enum,void volatile,false) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_enum,void const volatile,false) +#endif #else // __BORLANDC__ // diff --git a/include/boost/type_traits/is_integral.hpp b/include/boost/type_traits/is_integral.hpp index e02a468..50d32a6 100644 --- a/include/boost/type_traits/is_integral.hpp +++ b/include/boost/type_traits/is_integral.hpp @@ -39,6 +39,15 @@ BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,char,true) BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,wchar_t,true) #endif +#if defined(BOOST_MSVC) && (BOOST_MSVC == 1200) +BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,unsigned __int8,true) +BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,__int8,true) +BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,unsigned __int16,true) +BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,__int16,true) +BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,unsigned __int32,true) +BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,__int32,true) +#endif + # if defined(BOOST_HAS_LONG_LONG) BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,unsigned long long,true) BOOST_TT_AUX_BOOL_TRAIT_CV_SPEC1(is_integral,long long,true) diff --git a/include/boost/type_traits/is_pod.hpp b/include/boost/type_traits/is_pod.hpp index 907e1b3..700d1e4 100644 --- a/include/boost/type_traits/is_pod.hpp +++ b/include/boost/type_traits/is_pod.hpp @@ -116,6 +116,15 @@ template struct is_POD_impl BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_POD,T,::boost::detail::is_POD_impl::value) +// the following help compilers without partial specialization support: +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,void,true) + +#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,void const,true) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,void volatile,true) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,void const volatile,true) +#endif + } // namespace boost #include "boost/type_traits/detail/bool_trait_undef.hpp" diff --git a/include/boost/type_traits/is_pointer.hpp b/include/boost/type_traits/is_pointer.hpp index a483585..c8491d5 100644 --- a/include/boost/type_traits/is_pointer.hpp +++ b/include/boost/type_traits/is_pointer.hpp @@ -68,6 +68,16 @@ struct is_pointer_impl } // namespace detail BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pointer,T,::boost::detail::is_pointer_impl::value) +#ifdef __BORLANDC__ +template struct is_pointer +{ BOOST_STATIC_CONSTANT(bool, value = false); }; +template struct is_pointer +{ BOOST_STATIC_CONSTANT(bool, value = false); }; +template struct is_pointer +{ BOOST_STATIC_CONSTANT(bool, value = false); }; +template struct is_pointer +{ BOOST_STATIC_CONSTANT(bool, value = false); }; +#endif #else // no partial template specialization diff --git a/include/boost/type_traits/is_reference.hpp b/include/boost/type_traits/is_reference.hpp index 354d8be..3c9eca1 100644 --- a/include/boost/type_traits/is_reference.hpp +++ b/include/boost/type_traits/is_reference.hpp @@ -43,6 +43,13 @@ BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T& volatile,true BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T& const volatile,true) #endif +#ifdef __GNUC__ +// these allow us to work around illegally cv-qualified reference types. +BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T const ,::boost::is_reference::value) +BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T volatile ,::boost::is_reference::value) +BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T const volatile ,::boost::is_reference::value) +#endif + #else #ifdef BOOST_MSVC diff --git a/include/boost/type_traits/is_same.hpp b/include/boost/type_traits/is_same.hpp index 8cd18ab..d58f292 100644 --- a/include/boost/type_traits/is_same.hpp +++ b/include/boost/type_traits/is_same.hpp @@ -11,6 +11,12 @@ #ifndef BOOST_TT_IS_SAME_HPP_INCLUDED #define BOOST_TT_IS_SAME_HPP_INCLUDED +#include "boost/type_traits/config.hpp" +#ifdef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION +#include "boost/type_traits/detail/yes_no_type.hpp" +#include "boost/type_traits/detail/ice_and.hpp" +#include "boost/type_traits/is_reference.hpp" +#endif // should be the last #include #include "boost/type_traits/detail/bool_trait_def.hpp" @@ -79,3 +85,4 @@ BOOST_TT_AUX_BOOL_TRAIT_DEF2(is_same,T,U,(::boost::detail::is_same_impl::va #include "boost/type_traits/detail/bool_trait_undef.hpp" #endif // BOOST_TT_IS_SAME_HPP_INCLUDED + diff --git a/include/boost/type_traits/is_scalar.hpp b/include/boost/type_traits/is_scalar.hpp index 51f587f..5abd7ee 100644 --- a/include/boost/type_traits/is_scalar.hpp +++ b/include/boost/type_traits/is_scalar.hpp @@ -36,6 +36,15 @@ struct is_scalar_impl >::value)); }; +// these specializations are only really needed for compilers +// without partial specialization support: +template <> struct is_scalar_impl{ BOOST_STATIC_CONSTANT(bool, value = false ); }; +#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS +template <> struct is_scalar_impl{ BOOST_STATIC_CONSTANT(bool, value = false ); }; +template <> struct is_scalar_impl{ BOOST_STATIC_CONSTANT(bool, value = false ); }; +template <> struct is_scalar_impl{ BOOST_STATIC_CONSTANT(bool, value = false ); }; +#endif + } // namespace detail BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_scalar,T,::boost::detail::is_scalar_impl::value) diff --git a/include/boost/type_traits/type_with_alignment.hpp b/include/boost/type_traits/type_with_alignment.hpp index 03b6b1b..5f135d0 100644 --- a/include/boost/type_traits/type_with_alignment.hpp +++ b/include/boost/type_traits/type_with_alignment.hpp @@ -13,9 +13,13 @@ #include "boost/preprocessor/tuple/to_list.hpp" #include "boost/preprocessor/cat.hpp" #include "boost/type_traits/alignment_of.hpp" +#include "boost/type_traits/is_pod.hpp" #include "boost/static_assert.hpp" #include "boost/config.hpp" +// should be the last #include +#include "boost/type_traits/detail/bool_trait_def.hpp" + #include #ifdef BOOST_MSVC @@ -25,6 +29,8 @@ namespace boost { +#ifndef __BORLANDC__ + namespace detail { class alignment_dummy; @@ -76,6 +82,16 @@ struct is_aligned } // namespace detail +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,::boost::detail::max_align,true) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,detail::lower_alignment<1> ,true) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,::boost::detail::lower_alignment<2> ,true) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,::boost::detail::lower_alignment<4> ,true) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,::boost::detail::lower_alignment<8> ,true) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,::boost::detail::lower_alignment<10> ,true) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,::boost::detail::lower_alignment<16> ,true) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,::boost::detail::lower_alignment<32> ,true) + + // This alignment method originally due to Brian Parker, implemented by David // Abrahams, and then ported here by Doug Gregor. template @@ -90,17 +106,61 @@ class type_with_alignment BOOST_STATIC_CONSTANT(std::size_t, found = alignment_of::value); +#ifndef __BORLANDC__ BOOST_STATIC_ASSERT(found >= Align); BOOST_STATIC_ASSERT(found % Align == 0); +#else + BOOST_STATIC_ASSERT(::boost::type_with_alignment::found >= Align); + BOOST_STATIC_ASSERT(::boost::type_with_alignment::found % Align == 0); +#endif public: typedef align_t type; }; +#else + +// +// Borland specific version, we have this for two reasons: +// 1) The version above doesn't always compile (with the new test cases for example) +// 2) Because of Borlands #pragma option we can create types with alignments that are +// greater that the largest aligned builtin type. + +namespace align{ +#pragma option push -a16 +struct a2{ short s; }; +struct a4{ int s; }; +struct a8{ double s; }; +struct a16{ long double s; }; +#pragma option pop +} +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,::boost::align::a2,true) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,::boost::align::a4,true) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,::boost::align::a8,true) +BOOST_TT_AUX_BOOL_TRAIT_SPEC1(is_POD,::boost::align::a16,true) + +template struct type_with_alignment +{ + // We should never get to here, but if we do use the maximally + // aligned type: + // BOOST_STATIC_ASSERT(0); + typedef align::a16 type; +}; +template <> struct type_with_alignment<1>{ typedef char type; }; +template <> struct type_with_alignment<2>{ typedef align::a2 type; }; +template <> struct type_with_alignment<4>{ typedef align::a4 type; }; +template <> struct type_with_alignment<8>{ typedef align::a8 type; }; +template <> struct type_with_alignment<16>{ typedef align::a16 type; }; + +#endif + } // namespace boost #ifdef BOOST_MSVC # pragma warning(pop) #endif +#include "boost/type_traits/detail/bool_trait_undef.hpp" + #endif // BOOST_TT_TYPE_WITH_ALIGNMENT_INCLUDED +