forked from boostorg/type_traits
Misc. fixes mostly as a result of the new test programs.
[SVN r15973]
This commit is contained in:
@ -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<T&>
|
||||
{
|
||||
};
|
||||
#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<long double>
|
||||
: public alignment_of<long_double_wrapper>{};
|
||||
#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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
@ -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<sp> \
|
||||
template<> struct trait< sp > \
|
||||
: mpl::bool_c< C > \
|
||||
{ \
|
||||
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
|
||||
@ -62,7 +62,7 @@ template<> struct trait<sp> \
|
||||
/**/
|
||||
|
||||
#define BOOST_TT_AUX_BOOL_TRAIT_SPEC2(trait,sp1,sp2,C) \
|
||||
template<> struct trait<sp1,sp2> \
|
||||
template<> struct trait< sp1,sp2 > \
|
||||
: mpl::bool_c< C > \
|
||||
{ \
|
||||
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
|
||||
@ -71,7 +71,7 @@ template<> struct trait<sp1,sp2> \
|
||||
/**/
|
||||
|
||||
#define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(param,trait,sp,C) \
|
||||
template< param > struct trait<sp> \
|
||||
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<sp> \
|
||||
/**/
|
||||
|
||||
#define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_2(param1,param2,trait,sp,C) \
|
||||
template< param1, param2 > struct trait<sp> \
|
||||
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<sp> \
|
||||
/**/
|
||||
|
||||
#define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_1(param,trait,sp1,sp2,C) \
|
||||
template< param > struct trait<sp1,sp2> \
|
||||
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<sp1,sp2> \
|
||||
/**/
|
||||
|
||||
#define BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC2_2(param1,param2,trait,sp1,sp2,C) \
|
||||
template< param1, param2 > struct trait<sp1,sp2> \
|
||||
template< param1, param2 > struct trait< sp1,sp2 > \
|
||||
: mpl::bool_c< C > \
|
||||
{ \
|
||||
BOOST_TT_AUX_BOOL_TRAIT_VALUE_DECL(C) \
|
||||
|
@ -15,6 +15,9 @@
|
||||
|
||||
#ifndef BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION
|
||||
# include "boost/type_traits/detail/cv_traits_impl.hpp"
|
||||
# ifdef __GNUC__
|
||||
# include <boost/type_traits/is_reference.hpp>
|
||||
# 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<T>::value))
|
||||
BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_const,T volatile const,!(::boost::is_reference<T>::value))
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
namespace detail {
|
||||
|
@ -190,6 +190,14 @@ template <typename T> struct is_empty_impl
|
||||
} // namespace detail
|
||||
|
||||
BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_empty,T,::boost::detail::is_empty_impl<T>::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
|
||||
|
||||
|
@ -99,6 +99,13 @@ BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_enum,T,::boost::detail::is_enum_impl<T>::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__
|
||||
//
|
||||
|
@ -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)
|
||||
|
@ -116,6 +116,15 @@ template <typename T> struct is_POD_impl
|
||||
|
||||
BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_POD,T,::boost::detail::is_POD_impl<T>::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"
|
||||
|
@ -68,6 +68,16 @@ struct is_pointer_impl
|
||||
} // namespace detail
|
||||
|
||||
BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_pointer,T,::boost::detail::is_pointer_impl<T>::value)
|
||||
#ifdef __BORLANDC__
|
||||
template <class T> struct is_pointer<T&>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = false); };
|
||||
template <class T> struct is_pointer<T&const>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = false); };
|
||||
template <class T> struct is_pointer<T&volatile>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = false); };
|
||||
template <class T> struct is_pointer<T&const volatile>
|
||||
{ BOOST_STATIC_CONSTANT(bool, value = false); };
|
||||
#endif
|
||||
|
||||
#else // no partial template specialization
|
||||
|
||||
|
@ -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<T>::value)
|
||||
BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T volatile ,::boost::is_reference<T>::value)
|
||||
BOOST_TT_AUX_BOOL_TRAIT_PARTIAL_SPEC1_1(typename T,is_reference,T const volatile ,::boost::is_reference<T>::value)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifdef BOOST_MSVC
|
||||
|
@ -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<T,U>::va
|
||||
#include "boost/type_traits/detail/bool_trait_undef.hpp"
|
||||
|
||||
#endif // BOOST_TT_IS_SAME_HPP_INCLUDED
|
||||
|
||||
|
@ -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<void>{ BOOST_STATIC_CONSTANT(bool, value = false ); };
|
||||
#ifndef BOOST_NO_CV_VOID_SPECIALIZATIONS
|
||||
template <> struct is_scalar_impl<void const>{ BOOST_STATIC_CONSTANT(bool, value = false ); };
|
||||
template <> struct is_scalar_impl<void volatile>{ BOOST_STATIC_CONSTANT(bool, value = false ); };
|
||||
template <> struct is_scalar_impl<void const volatile>{ BOOST_STATIC_CONSTANT(bool, value = false ); };
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
BOOST_TT_AUX_BOOL_TRAIT_DEF1(is_scalar,T,::boost::detail::is_scalar_impl<T>::value)
|
||||
|
@ -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 <cstddef>
|
||||
|
||||
#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 <int Align>
|
||||
@ -90,17 +106,61 @@ class type_with_alignment
|
||||
|
||||
BOOST_STATIC_CONSTANT(std::size_t, found = alignment_of<align_t>::value);
|
||||
|
||||
#ifndef __BORLANDC__
|
||||
BOOST_STATIC_ASSERT(found >= Align);
|
||||
BOOST_STATIC_ASSERT(found % Align == 0);
|
||||
#else
|
||||
BOOST_STATIC_ASSERT(::boost::type_with_alignment<Align>::found >= Align);
|
||||
BOOST_STATIC_ASSERT(::boost::type_with_alignment<Align>::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 <std::size_t N> 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
|
||||
|
||||
|
Reference in New Issue
Block a user