Add equality operators

This commit is contained in:
King_DuckZ 2022-05-24 16:07:16 +02:00
commit e8db08931a
3 changed files with 74 additions and 0 deletions

30
src/module_and_name.cpp Normal file
View file

@ -0,0 +1,30 @@
/* Copyright 2020-2022, Michele Santullo
* This file is part of wrenpp.
*
* Wrenpp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Wrenpp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with wrenpp. If not, see <http://www.gnu.org/licenses/>.
*/
#include "wrenpp/detail/module_and_name.hpp"
#include <algorithm>
namespace wren::detail {
bool deep_equal(const ModuleAndName& a, const ModuleAndName& b) noexcept {
const auto a_size = a.raw_buffer_size();
const auto b_size = b.raw_buffer_size();
if (a_size != b_size)
return false;
return std::equal(a.m_base, a.m_base + a_size, b.m_base);
}
} //namespace wren::detail