Changeset 66:1300ac71fd7d in finroc_plugins_data_ports


Ignore:
Timestamp:
17.04.2014 13:30:48 (5 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Phase:
public
Message:

Proper fix for IsString type trait

File:
1 edited

Legend:

Unmodified
Added
Removed
  • type_traits.h

    r65 r66  
    150150struct IsString 
    151151{ 
    152   enum { value = std::is_same<T, std::string>::value || std::is_same<T, tString>::value || std::is_same<T, char*>::value || std::is_same<T, const char*>::value || std::is_same<typename std::remove_extent<T>::type, char>::value }; 
    153 }; 
     152  typedef typename std::remove_const<typename std::remove_reference<T>::type>::type U; 
    154153 
    155 template <size_t Tsize> 
    156 struct IsString<char(&) [Tsize]> 
    157 { 
    158   enum { value = 1 }; 
    159 }; 
    160  
    161 template <size_t Tsize> 
    162 struct IsString<const char(&) [Tsize]> 
    163 { 
    164   enum { value = 1 }; 
     154  enum { value = std::is_same<U, std::string>::value || std::is_same<U, tString>::value || std::is_same<U, char*>::value || std::is_same<U, const char*>::value || std::is_same<typename std::remove_extent<U>::type, char>::value }; 
    165155}; 
    166156 
    167157static_assert(IsString<char const(&) [9]>::value, "Error in trait implementation"); 
     158static_assert(IsString<std::string const&>::value, "Error in trait implementation"); 
    168159 
    169160//---------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.