Skip to content

Move C++ virtual destructor definition to .cpp files (#21529) #21530

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class {{declspec}} {{classname}}
{
public:
{{classname}}();
virtual ~{{classname}}() = default;
virtual ~{{classname}}();
{{#isEnum}}{{#allowableValues}}
enum class e{{classname}} {
// To have a valid default value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ namespace {{modelNamespace}}
{{/required}}{{/vars}}
}

{{classname}}::~{{classname}}() = default;

void {{classname}}::validate() const
{
std::stringstream msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class {{declspec}} {{classname}} {{#interfaces}}{{#-first}}:{{/-first}}{{^-first
public:
{{classname}}() = default;
explicit {{classname}}(boost::property_tree::ptree const& pt);
virtual ~{{classname}}() = default;
virtual ~{{classname}}();

std::string toJsonString(bool prettyJson = false);
void fromJsonString(std::string const& jsonString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace {{this}} {
fromPropertyTree(pt);
}

{{classname}}::~{{classname}}() = default;

std::string {{classname}}::toJsonString(bool prettyJson /* = false */)
{
return toJsonString_internal(prettyJson);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class {{declspec}} {{vendorExtensions.x-codegen-resource-name}}Resource: public
{
public:
{{vendorExtensions.x-codegen-resource-name}}Resource(const std::string& context = "{{contextPath}}");
virtual ~{{vendorExtensions.x-codegen-resource-name}}Resource() = default;
virtual ~{{vendorExtensions.x-codegen-resource-name}}Resource();

{{vendorExtensions.x-codegen-resource-name}}Resource(
const {{vendorExtensions.x-codegen-resource-name}}Resource& other) = default; // copy constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ namespace {{classname}}Resources {
{{/vendorExtensions.x-codegen-other-methods}}
}

{{vendorExtensions.x-codegen-resource-name}}Resource::~{{vendorExtensions.x-codegen-resource-name}}Resource() = default;

std::pair<int, std::string> {{vendorExtensions.x-codegen-resource-name}}Resource::handle{{classname}}Exception(const {{classname}}Exception& e)
{
return std::make_pair<int, std::string>(e.getStatus(), e.what());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class {{declspec}} {{classname}} {{#interfaces}}{{#-first}}:{{/-first}}{{^-first
public:
{{classname}}() = default;
explicit {{classname}}(boost::property_tree::ptree const& pt);
virtual ~{{classname}}() = default;
virtual ~{{classname}}();

{{classname}}(const {{classname}}& other) = default; // copy constructor
{{classname}}({{classname}}&& other) noexcept = default; // move constructor
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ namespace {{this}} {
fromPropertyTree(pt);
}

{{classname}}::~{{classname}} = default;

std::string {{classname}}::toJsonString(bool prettyJson /* = false */) const
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public:
{{classname}}() = default;

{{! Destructor }}
virtual ~{{classname}}() = default;
virtual ~{{classname}}();

{{! Service endpoint }}
{{#operation}}
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpp-tiny/lib/service/PetApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class PetApi : public Service {
public:
PetApi() = default;

virtual ~PetApi() = default;
virtual ~PetApi();

/**
* Add a new pet to the store.
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpp-tiny/lib/service/StoreApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class StoreApi : public Service {
public:
StoreApi() = default;

virtual ~StoreApi() = default;
virtual ~StoreApi();

/**
* Delete purchase order by ID.
Expand Down
2 changes: 1 addition & 1 deletion samples/client/petstore/cpp-tiny/lib/service/UserApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class UserApi : public Service {
public:
UserApi() = default;

virtual ~UserApi() = default;
virtual ~UserApi();

/**
* Create user.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ ApiResponse::ApiResponse()

}

ApiResponse::~ApiResponse() = default;

void ApiResponse::validate() const
{
std::stringstream msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ApiResponse
{
public:
ApiResponse();
virtual ~ApiResponse() = default;
virtual ~ApiResponse();


/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Category::Category()

}

Category::~Category() = default;

void Category::validate() const
{
std::stringstream msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Category
{
public:
Category();
virtual ~Category() = default;
virtual ~Category();


/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Order::Order()

}

Order::~Order() = default;

void Order::validate() const
{
std::stringstream msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Order
{
public:
Order();
virtual ~Order() = default;
virtual ~Order();


/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions samples/server/petstore/cpp-pistache-everything/model/Pet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Pet::Pet()

}

Pet::~Pet() = default;

void Pet::validate() const
{
std::stringstream msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class Pet
{
public:
Pet();
virtual ~Pet() = default;
virtual ~Pet();


/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Pet_vaccinationBook::Pet_vaccinationBook()

}

Pet_vaccinationBook::~Pet_vaccinationBook() = default;

void Pet_vaccinationBook::validate() const
{
std::stringstream msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class Pet_vaccinationBook
{
public:
Pet_vaccinationBook();
virtual ~Pet_vaccinationBook() = default;
virtual ~Pet_vaccinationBook();


/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions samples/server/petstore/cpp-pistache-everything/model/Tag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Tag::Tag()

}

Tag::~Tag() = default;

void Tag::validate() const
{
std::stringstream msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Tag
{
public:
Tag();
virtual ~Tag() = default;
virtual ~Tag();


/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ User::User()

}

User::~User() = default;

void User::validate() const
{
std::stringstream msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class User
{
public:
User();
virtual ~User() = default;
virtual ~User();


/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ Vaccine::Vaccine()

}

Vaccine::~Vaccine() = default;

void Vaccine::validate() const
{
std::stringstream msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Vaccine
{
public:
Vaccine();
virtual ~Vaccine() = default;
virtual ~Vaccine();


/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ MiddleType::MiddleType()

}

MiddleType::~MiddleType() = default;

void MiddleType::validate() const
{
std::stringstream msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class MiddleType
{
public:
MiddleType();
virtual ~MiddleType() = default;
virtual ~MiddleType();


/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ OuterType::OuterType()

}

OuterType::~OuterType() = default;

void OuterType::validate() const
{
std::stringstream msg;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class OuterType
{
public:
OuterType();
virtual ~OuterType() = default;
virtual ~OuterType();


/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions samples/server/petstore/cpp-pistache/model/ApiResponse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ ApiResponse::ApiResponse()

}

ApiResponse::~ApiResponse() = default;

void ApiResponse::validate() const
{
std::stringstream msg;
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-pistache/model/ApiResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ApiResponse
{
public:
ApiResponse();
virtual ~ApiResponse() = default;
virtual ~ApiResponse();


/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions samples/server/petstore/cpp-pistache/model/Category.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Category::Category()

}

Category::~Category() = default;

void Category::validate() const
{
std::stringstream msg;
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-pistache/model/Category.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Category
{
public:
Category();
virtual ~Category() = default;
virtual ~Category();


/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions samples/server/petstore/cpp-pistache/model/Order.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ Order::Order()

}

Order::~Order() = default;

void Order::validate() const
{
std::stringstream msg;
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-pistache/model/Order.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Order
{
public:
Order();
virtual ~Order() = default;
virtual ~Order();


/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions samples/server/petstore/cpp-pistache/model/Pet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ Pet::Pet()

}

Pet::~Pet() = default;

void Pet::validate() const
{
std::stringstream msg;
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-pistache/model/Pet.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Pet
{
public:
Pet();
virtual ~Pet() = default;
virtual ~Pet();


/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions samples/server/petstore/cpp-pistache/model/Tag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ Tag::Tag()

}

Tag::~Tag() = default;

void Tag::validate() const
{
std::stringstream msg;
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-pistache/model/Tag.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Tag
{
public:
Tag();
virtual ~Tag() = default;
virtual ~Tag();


/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions samples/server/petstore/cpp-pistache/model/User.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ User::User()

}

User::~User() = default;

void User::validate() const
{
std::stringstream msg;
Expand Down
2 changes: 1 addition & 1 deletion samples/server/petstore/cpp-pistache/model/User.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class User
{
public:
User();
virtual ~User() = default;
virtual ~User();


/// <summary>
Expand Down
Loading
Loading