Repository: oatpp/oatpp
File: src/oatpp/core/data/mapping/type/Primitive.hpp (C++)

Code before:
    m_ptr = std::move(other.m_ptr);
    return *this;
  }


  inline bool equalsCI(const std::string &sb) {
    const std::string& sa = this->m_ptr.operator*();
    return (sa.size() == sb.size()) && std::equal(sa.begin(), sa.end(), sb.begin(),
                      [] (char a, char b) -> bool {
                          return std::tolower(a) == std::tolower(b);
                      });
  }

  inline bool equalsCI(const String &b) {
    const std::string& sb = *b;
    return this->equalsCI(sb);
  }

  inline bool equalsCI(const char *b) {
    const std::string sb(b);
    return this->equalsCI(sb);
  }

  template<typename T,
    typename enabled = typename std::enable_if<std::is_same<T, std::nullptr_t>::value, void>::type
  >
  inline bool operator == (T) const {
    return m_ptr.get() == nullptr;
  }

  template<typename T,
    typename enabled = typename std::enable_if<std::is_same<T, std::nullptr_t>::value, void>::type
  >
  inline bool operator != (T) const {
    return m_ptr.get() != nullptr;
  }

  template<typename T,
    typename enabled = typename std::enable_if<std::is_same<T, char>::value, void>::type
  >
  inline bool operator == (const T* str) const {
    if(!m_ptr) return str == nullptr;
    if(str == nullptr) return false;
    return *m_ptr == str;
  }

  template<typename T,
    typename enabled = typename std::enable_if<std::is_same<T, char>::value, void>::type
  >
  inline bool operator != (const T* str) const {
    return !operator == (str);

Review comment (bug):
Should return `true` if both `this->m_ptr == nullptr` and `b == nullptr`
Should return `false` if `this->m_ptr != nullptr` and `b == nullptr`
Should return `false` if `this->m_ptr == nullptr` and `b != nullptr`

Code after:
  }

  inline String& operator = (String&& other) noexcept {
    m_ptr = std::move(other.m_ptr);
    return *this;
  }


  inline bool equalsCI(const std::string &sb) {
    if (this->m_ptr == nullptr ) return false;
    const std::string& sa = this->m_ptr.operator*();
    return (sa.size() == sb.size()) && std::equal(sa.begin(), sa.end(), sb.begin(),
                      [] (char a, char b) -> bool {
                          return std::tolower(a) == std::tolower(b);
                      });
  }

  inline bool equalsCI(const String &b) {
    if (this->m_ptr == nullptr && b.m_ptr == nullptr) return true;
    if (this->m_ptr == nullptr && b.m_ptr != nullptr) return false;
    if (this->m_ptr != nullptr && b.m_ptr == nullptr) return false;
    const std::string& sb = *b;
    return this->equalsCI(sb);
  }

  inline bool equalsCI(const char *b) {
    if (this->m_ptr == nullptr && b == nullptr) return true;
    if (this->m_ptr == nullptr && b != nullptr) return false;
    if (this->m_ptr != nullptr && b == nullptr) return false;

    size_t lb = strlen(b);
    const std::string& sa = this->m_ptr.operator*();

    if (sa.size() != lb) return false;
    const char *ba = b;

    for ( const auto &ca: sa ) {
      if ( std::tolower(ca) != std::tolower(*ba)) return false;
      ba++;
    }
    return true;
  }

  template<typename T,
    typename enabled = typename std::enable_if<std::is_same<T, std::nullptr_t>::value, void>::type
  >
  inline bool operator == (T) const {
    return m_ptr.get() == nullptr;
  }

  template<typename T,