Changeset 20:c8365294522d in rrlib_rtti_conversion


Ignore:
Timestamp:
03.02.2020 06:44:53 (3 weeks ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Children:
21:9e5fed94ff31, 22:fed7ec8deba0
Phase:
public
Message:

Makes static cast operation handle more (valid) cases including implicit casts in a single conversion operation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tStaticCastOperation.cpp

    r18 r20  
    158158  } 
    159159  tCommonUnderlyingTypeResult result = GetCommonUnderlyingType(source_type, destination_type); 
    160   if (result.common_underlying_type == destination_type || (result.common_underlying_type == source_type && result.cast_from_common_to_destination_type_valid)) 
     160  if (result.common_underlying_type == destination_type || (result.cast_from_common_to_destination_type_valid && (result.common_underlying_type == source_type || result.cast_from_common_to_destination_type_implicit || result.cast_from_source_to_common_type_implicit))) 
    161161  { 
    162162    return tConversionOption(source_type, destination_type, 0); 
     
    168168    { 
    169169      return option->conversion_option; 
     170    } 
     171 
     172    if (option->implicit) 
     173    { 
     174      // Combining (non-implicit) underlying type casts with implicit casts can be done in a single operation 
     175      tType underlying_type_source = source_type; 
     176      while (underlying_type_source.GetUnderlyingType() != underlying_type_source) 
     177      { 
     178        underlying_type_source = underlying_type_source.GetUnderlyingType(); 
     179        if (underlying_type_source == option->conversion_option.source_type && destination_type == option->conversion_option.destination_type) 
     180        { 
     181          return option->conversion_option; 
     182        } 
     183      } 
    170184    } 
    171185  } 
Note: See TracChangeset for help on using the changeset viewer.