2
0
mirror of https://github.com/boostorg/mysql.git synced 2026-02-02 09:02:09 +00:00

Added operator== between rows and owning rows

This commit is contained in:
ruben
2019-12-07 21:40:39 +00:00
parent fe8f57ae38
commit 0dcd46233f
2 changed files with 17 additions and 5 deletions

View File

@@ -9,10 +9,10 @@ namespace mysql
namespace detail
{
template <typename T>
template <typename TLeft, typename TRight>
inline bool container_equals(
const std::vector<T>& lhs,
const std::vector<T>& rhs
const std::vector<TLeft>& lhs,
const std::vector<TRight>& rhs
)
{
if (lhs.size() != rhs.size()) return false;

View File

@@ -43,11 +43,23 @@ public:
inline bool operator==(const row& lhs, const row& rhs) { return lhs.values() == rhs.values(); }
inline bool operator!=(const row& lhs, const row& rhs) { return !(lhs == rhs); }
inline bool operator==(const std::vector<owning_row>& lhs, const std::vector<owning_row>& rhs)
// Allow comparisons between vectors of rows and owning rows
template <
typename RowTypeLeft,
typename RowTypeRight,
typename=std::enable_if_t<std::is_base_of_v<row, RowTypeLeft> && std::is_base_of_v<row, RowTypeRight>>
>
inline bool operator==(const std::vector<RowTypeLeft>& lhs, const std::vector<RowTypeRight>& rhs)
{
return detail::container_equals(lhs, rhs);
}
inline bool operator!=(const std::vector<owning_row>& lhs, const std::vector<owning_row>& rhs)
template <
typename RowTypeLeft,
typename RowTypeRight,
typename=std::enable_if_t<std::is_base_of_v<row, RowTypeLeft> && std::is_base_of_v<row, RowTypeRight>>
>
inline bool operator!=(const std::vector<RowTypeLeft>& lhs, const std::vector<RowTypeRight>& rhs)
{
return !(lhs == rhs);
}