mirror of
https://github.com/nlohmann/json.git
synced 2026-02-21 19:06:27 +00:00
Fix weak-vtables warning (#4500)
* 🔧 remove warning suppression * 🚨 fix weak-vtables warning #4087 * 🚨 suppress -Wweak-vtables warning * 🚨 suppress -Wweak-vtables warning * ✅ fix test * ✅ fix test * ✅ fix test
This commit is contained in:
@@ -233,7 +233,33 @@ inline void from_json(const nlohmann::json& j, FooBar& fb) // NOLINT(misc-use-in
|
||||
struct for_3171_base // NOLINT(cppcoreguidelines-special-member-functions)
|
||||
{
|
||||
for_3171_base(const std::string& /*unused*/ = {}) {}
|
||||
virtual ~for_3171_base() = default;
|
||||
virtual ~for_3171_base();
|
||||
|
||||
for_3171_base(const for_3171_base& other) // NOLINT(hicpp-use-equals-default,modernize-use-equals-default)
|
||||
: str(other.str)
|
||||
{}
|
||||
|
||||
for_3171_base& operator=(const for_3171_base& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
str = other.str;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
for_3171_base(for_3171_base&& other) noexcept
|
||||
: str(std::move(other.str))
|
||||
{}
|
||||
|
||||
for_3171_base& operator=(for_3171_base&& other) noexcept
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
str = std::move(other.str);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
virtual void _from_json(const json& j)
|
||||
{
|
||||
@@ -243,12 +269,43 @@ struct for_3171_base // NOLINT(cppcoreguidelines-special-member-functions)
|
||||
std::string str{}; // NOLINT(readability-redundant-member-init)
|
||||
};
|
||||
|
||||
for_3171_base::~for_3171_base() = default;
|
||||
|
||||
struct for_3171_derived : public for_3171_base
|
||||
{
|
||||
for_3171_derived() = default;
|
||||
~for_3171_derived() override;
|
||||
explicit for_3171_derived(const std::string& /*unused*/) { }
|
||||
|
||||
for_3171_derived(const for_3171_derived& other) // NOLINT(hicpp-use-equals-default,modernize-use-equals-default)
|
||||
: for_3171_base(other)
|
||||
{}
|
||||
|
||||
for_3171_derived& operator=(const for_3171_derived& other)
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
for_3171_base::operator=(other); // Call base class assignment operator
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
for_3171_derived(for_3171_derived&& other) noexcept
|
||||
: for_3171_base(std::move(other))
|
||||
{}
|
||||
|
||||
for_3171_derived& operator=(for_3171_derived&& other) noexcept
|
||||
{
|
||||
if (this != &other)
|
||||
{
|
||||
for_3171_base::operator=(std::move(other)); // Call base class move assignment operator
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
};
|
||||
|
||||
for_3171_derived::~for_3171_derived() = default;
|
||||
|
||||
inline void from_json(const json& j, for_3171_base& tb) // NOLINT(misc-use-internal-linkage)
|
||||
{
|
||||
tb._from_json(j);
|
||||
|
||||
Reference in New Issue
Block a user