mirror of https://github.com/OpenMW/openmw.git
Make sure Vec2iRefId is trivially copyable on GCC 11.3
std::pair<int, int> isn't trivially copyable on some compilers so a specific struct is defined, it's an int pair, but it should be recognised by GCC 11.3 as trivially copyable Vec2iRefId => ESM3ExteriorCellRefId more explcit name and use mX,mY instead of pair renamed files and enumdepth-refraction
parent
53b14c8b42
commit
d782d37ee2
@ -0,0 +1,26 @@
|
||||
#include "esm3exteriorcellrefid.hpp"
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
std::string ESM3ExteriorCellRefId::toString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "# " << mY << ", " << mY;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::string ESM3ExteriorCellRefId::toDebugString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << *this;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& stream, ESM3ExteriorCellRefId value)
|
||||
{
|
||||
return stream << "Vec2i{" << value.mX << "," << value.mY << '}';
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
#ifndef OPENMW_COMPONENTS_ESM_ESM3EXTERIORCELLREFID_HPP
|
||||
#define OPENMW_COMPONENTS_ESM_ESM3EXTERIORCELLREFID_HPP
|
||||
|
||||
#include <functional>
|
||||
#include <iosfwd>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESM3ExteriorCellRefId
|
||||
{
|
||||
public:
|
||||
constexpr ESM3ExteriorCellRefId() = default;
|
||||
|
||||
constexpr explicit ESM3ExteriorCellRefId(int32_t x, int32_t y) noexcept
|
||||
: mX(x)
|
||||
, mY(y)
|
||||
{
|
||||
}
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
std::string toDebugString() const;
|
||||
|
||||
int32_t getX() const { return mX; }
|
||||
int32_t getY() const { return mY; }
|
||||
|
||||
constexpr bool operator==(ESM3ExteriorCellRefId rhs) const noexcept { return mX == rhs.mX && mY == rhs.mY; }
|
||||
|
||||
constexpr bool operator<(ESM3ExteriorCellRefId rhs) const noexcept { return mX < rhs.mX && mY < rhs.mY; }
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& stream, ESM3ExteriorCellRefId value);
|
||||
|
||||
friend struct std::hash<ESM3ExteriorCellRefId>;
|
||||
|
||||
private:
|
||||
int32_t mX = 0;
|
||||
int32_t mY = 0;
|
||||
};
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<ESM::ESM3ExteriorCellRefId>
|
||||
{
|
||||
std::size_t operator()(ESM::ESM3ExteriorCellRefId value) const noexcept
|
||||
{
|
||||
return (53 + std::hash<int32_t>{}(value.mX)) * 53 + std::hash<int32_t>{}(value.mY);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
@ -1,26 +0,0 @@
|
||||
#include "vec2irefid.hpp"
|
||||
|
||||
#include <ostream>
|
||||
#include <sstream>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
std::string Vec2iRefId::toString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << "# " << mValue.first << ", " << mValue.second;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::string Vec2iRefId::toDebugString() const
|
||||
{
|
||||
std::ostringstream stream;
|
||||
stream << *this;
|
||||
return stream.str();
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& stream, Vec2iRefId value)
|
||||
{
|
||||
return stream << "Vec2i{" << value.mValue.first << "," << value.mValue.second << '}';
|
||||
}
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
#ifndef OPENMW_COMPONENTS_ESM_VEC2IREFID_HPP
|
||||
#define OPENMW_COMPONENTS_ESM_VEC2IREFID_HPP
|
||||
|
||||
#include <functional>
|
||||
#include <iosfwd>
|
||||
|
||||
#include <utility>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class Vec2iRefId
|
||||
{
|
||||
public:
|
||||
constexpr Vec2iRefId() = default;
|
||||
|
||||
constexpr explicit Vec2iRefId(std::pair<int32_t, int32_t> value) noexcept
|
||||
: mValue(value)
|
||||
{
|
||||
}
|
||||
|
||||
std::pair<int32_t, int32_t> getValue() const { return mValue; }
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
std::string toDebugString() const;
|
||||
|
||||
constexpr bool operator==(Vec2iRefId rhs) const noexcept { return mValue == rhs.mValue; }
|
||||
|
||||
constexpr bool operator<(Vec2iRefId rhs) const noexcept { return mValue < rhs.mValue; }
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& stream, Vec2iRefId value);
|
||||
|
||||
friend struct std::hash<Vec2iRefId>;
|
||||
|
||||
private:
|
||||
std::pair<int32_t, int32_t> mValue = std::pair<int32_t, int32_t>(0, 0);
|
||||
};
|
||||
}
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<ESM::Vec2iRefId>
|
||||
{
|
||||
std::size_t operator()(ESM::Vec2iRefId value) const noexcept
|
||||
{
|
||||
return (53 + std::hash<int32_t>{}(value.mValue.first)) * 53 + std::hash<int32_t>{}(value.mValue.second);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue