forked from boostorg/type_traits
Fix for type-punning warnings from gcc.
See: https://svn.boost.org/trac10/ticket/13479
This commit is contained in:
@ -56,17 +56,12 @@ namespace boost{
|
||||
typedef T value_type;
|
||||
typedef integral_constant<T, val> type;
|
||||
static const T value = val;
|
||||
//
|
||||
// This helper function is just to disable type-punning
|
||||
// warnings from GCC:
|
||||
//
|
||||
template <class U>
|
||||
static U& dereference(U* p) { return *p; }
|
||||
|
||||
operator const mpl::integral_c<T, val>& ()const
|
||||
{
|
||||
static const char data[sizeof(long)] = { 0 };
|
||||
return dereference(reinterpret_cast<const mpl::integral_c<T, val>*>(&data));
|
||||
static const void* pdata = data;
|
||||
return *(reinterpret_cast<const mpl::integral_c<T, val>*>(pdata));
|
||||
}
|
||||
BOOST_CONSTEXPR operator T()const { return val; }
|
||||
};
|
||||
@ -81,17 +76,12 @@ namespace boost{
|
||||
typedef bool value_type;
|
||||
typedef integral_constant<bool, val> type;
|
||||
static const bool value = val;
|
||||
//
|
||||
// This helper function is just to disable type-punning
|
||||
// warnings from GCC:
|
||||
//
|
||||
template <class T>
|
||||
static T& dereference(T* p) { return *p; }
|
||||
|
||||
operator const mpl::bool_<val>& ()const
|
||||
{
|
||||
static const char data = 0;
|
||||
return dereference(reinterpret_cast<const mpl::bool_<val>*>(&data));
|
||||
static const char data[sizeof(long)] = { 0 };
|
||||
static const void* pdata = data;
|
||||
return *(reinterpret_cast<const mpl::bool_<val>*>(pdata));
|
||||
}
|
||||
BOOST_CONSTEXPR operator bool()const { return val; }
|
||||
};
|
||||
|
Reference in New Issue
Block a user