Changeset 113:19aca1477e99 in rrlib_rtti


Ignore:
Timestamp:
28.01.2019 15:33:10 (9 months ago)
Author:
Max Reichardt <max.reichardt@…>
Branch:
17.03
Children:
114:8c2758822391, 115:1b996ddfb1cc
Phase:
public
Message:

Adds 'INHERITS_UNDERLYING_TYPE_ELEMENT_ACCESS_OPERATIONS' flag to tUnderlyingType type trait. This allows to use built-in element access operation '[]' for e.g. rrlib_math vectors also.

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • detail/type_traits.h

    r90 r113  
    4949namespace rtti 
    5050{ 
    51 namespace detail 
    52 { 
    5351 
    5452//---------------------------------------------------------------------- 
     
    5654//---------------------------------------------------------------------- 
    5755 
     56template <typename T> 
     57struct UnderlyingType; 
     58 
    5859//---------------------------------------------------------------------- 
    5960// Function declarations 
    6061//---------------------------------------------------------------------- 
     62 
     63namespace detail 
     64{ 
    6165 
    6266/*! 
     
    134138}; 
    135139 
     140/*! 
     141 * Type trait to extract optional cINHERITS_ELEMENT_ACCESS_CONVERSION_OPERATIONS from UnderlyingType type trait 
     142 */ 
     143template <typename T> 
     144struct InheritsUnderlyingTypeElementAccessOperations 
     145{ 
     146  template <typename U = T> 
     147  static int16_t Test(typename std::enable_if<UnderlyingType<U>::cINHERITS_ELEMENT_ACCESS_CONVERSION_OPERATIONS, int>::type = 1); 
     148  static int32_t Test(...); 
     149 
     150  enum { value = sizeof(Test(1)) == sizeof(int16_t) }; 
     151}; 
     152 
    136153//---------------------------------------------------------------------- 
    137154// End of namespace declaration 
  • type_traits.h

    r104 r113  
    149149  /*! True if types T and 'type' have different string and/or XML serialization */ 
    150150  enum { cOTHER_SERIALIZATION_DIFFERS = true }; 
     151 
     152  /*! Optional - if underlying type is e.g. std::array, will inherit element access operations from it (as defined in rrlib_rtti_conversion/defined_conversions.h) */ 
     153  enum { cINHERITS_ELEMENT_ACCESS_CONVERSION_OPERATIONS = false }; 
    151154}; 
    152155 
     
    387390 
    388391static const int cHAS_TRIVIAL_DESTRUCTOR = 1 << 22; 
     392static const int cINHERITS_UNDERLYING_TYPE_ELEMENT_ACCESS_OPERATIONS = 1 << 23; 
    389393 
    390394static const int cHAS_VIRTUAL_DESTRUCTOR = 1 << 24; 
     
    428432    (std::has_virtual_destructor<T>::value ? trait_flags::cHAS_VIRTUAL_DESTRUCTOR : 0) | 
    429433    (std::is_trivially_destructible<T>::value ? trait_flags::cHAS_TRIVIAL_DESTRUCTOR : 0) | 
    430     (IsDefaultConstructionZeroMemory<T>::value ? trait_flags::cIS_DEFAULT_CONSTRUCTION_ZERO_MEMORY : 0) 
     434    (IsDefaultConstructionZeroMemory<T>::value ? trait_flags::cIS_DEFAULT_CONSTRUCTION_ZERO_MEMORY : 0) | 
     435    (detail::InheritsUnderlyingTypeElementAccessOperations<T>::value ? trait_flags::cINHERITS_UNDERLYING_TYPE_ELEMENT_ACCESS_OPERATIONS : 0) 
    431436    ; 
    432437 
Note: See TracChangeset for help on using the changeset viewer.