Changeset 139:db90278712af in rrlib_rtti


Ignore:
Timestamp:
11.03.2020 06:42:29 (2 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Children:
140:5822ca2704ab, 141:856abcec17ae
Phase:
public
Message:

Allows implicit casts from arithmetic types to bool (in IsImplicitlyConvertible type trait)

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tests/rtti.cpp

    r124 r139  
    8181static_assert(std::is_same<typename rrlib::rtti::NormalizedType<bool>::type, bool>::value, "Invalid trait implementation"); 
    8282static_assert(std::is_same<typename rrlib::rtti::NormalizedType<unsigned long>::type, typename std::conditional<sizeof(unsigned long) == 8, unsigned long long, unsigned int>::type>::value, "Invalid trait implementation"); 
     83static_assert(IsImplicitlyConvertible<double, bool>::value, "Trait not implemented correctly"); 
    8384 
    8485//---------------------------------------------------------------------- 
  • type_traits.h

    r136 r139  
    9999{ 
    100100  /*! Enforce explicit casts (for arithmetic types)? */ 
    101   enum { cENFORCE_EXPLICIT_CAST = std::is_arithmetic<TSource>::value && std::is_arithmetic<TDestination>::value && 
     101  enum { cENFORCE_EXPLICIT_CAST = std::is_arithmetic<TSource>::value && std::is_arithmetic<TDestination>::value && (!std::is_same<TDestination, bool>::value) && 
    102102                                  ((std::is_signed<TSource>::value && std::is_unsigned<TDestination>::value) ||   // sign-loss shall be explicit 
    103103                                   (sizeof(TSource) > sizeof(TDestination) || // information-loss shall be explicit 
Note: See TracChangeset for help on using the changeset viewer.