Changeset 120:fffcc9167a37 in finroc_plugins_data_ports


Ignore:
Timestamp:
11.08.2017 19:23:35 (2 years ago)
Author:
Max Reichardt <max.reichardt@…>
Branch:
17.03
Phase:
public
Message:

Registers casting operations for tNumber

Location:
numeric
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • numeric/tNumber.cpp

    r101 r120  
    3434//---------------------------------------------------------------------- 
    3535#include "rrlib/rtti/rtti.h" 
     36#include "rrlib/rtti_conversion/tStaticCastOperation.h" 
    3637#include "core/definitions.h" 
    3738#include "core/log_messages.h" 
     
    7374/*! Initializes tNumber data type */ 
    7475static rrlib::rtti::tDataType<tNumber> cINIT_DATA_TYPE("Number"); 
     76 
     77auto& cNUMBER_TYPE_CASTS = rrlib::rtti::conversion::tStaticCastOperation:: 
     78                           Register<tNumber, int8_t, true>() 
     79                           .Register<tNumber, int16_t, true>() 
     80                           .Register<tNumber, int32_t, true>() 
     81                           .Register<tNumber, int64_t, true>() 
     82                           .Register<tNumber, uint8_t, true>() 
     83                           .Register<tNumber, uint16_t, true>() 
     84                           .Register<tNumber, uint32_t, true>() 
     85                           .Register<tNumber, uint64_t, true>() 
     86                           .Register<tNumber, float, true>() 
     87                           .Register<tNumber, double, true>(); 
    7588 
    7689//---------------------------------------------------------------------- 
  • numeric/tNumber.h

    r101 r120  
    162162  bool operator<(const tNumber& other) const; 
    163163 
     164  template <typename T> 
     165  explicit operator T() const 
     166  { 
     167    return Value<T>(); 
     168  } 
     169 
    164170//---------------------------------------------------------------------- 
    165171// Private fields and methods 
Note: See TracChangeset for help on using the changeset viewer.