Skip to content
Merged
Changes from 1 commit
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
10 changes: 8 additions & 2 deletions tests/test_return_value_policy_override.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ struct obj {
struct nocopy {
std::string mtxt;
nocopy(const std::string &mtxt_) : mtxt(mtxt_) {}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you still need to delete the copy ctor?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing this out. I forgot this. I deleted the copy ctor.

nocopy(const nocopy &) = delete;
nocopy(nocopy &&other) { mtxt = other.mtxt + "_MvCtor"; }
nocopy &operator=(const nocopy &) = delete;
nocopy &operator=(nocopy &&other) {
mtxt = other.mtxt + "_MvCtor";
return *this;
Expand All @@ -51,9 +53,13 @@ const obj &return_const_reference() {
return value;
}

std::shared_ptr<obj> return_shared_pointer() { return std::make_shared<obj>("shared_pointer"); }
std::shared_ptr<obj> return_shared_pointer() {
return std::shared_ptr<obj>(new obj("shared_pointer"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be std::make_shared, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initially I used std::make_shared and std::make_unqiue, but then I see errors note: ‘std::make_unique’ is only available from C++14 onwards, so I modified both of them. I should be able to use std::make_shared with C++11. I will update the PR.

}

std::unique_ptr<obj> return_unique_pointer() { return std::make_unique<obj>("unique_pointer"); }
std::unique_ptr<obj> return_unique_pointer() {
return std::unique_ptr<obj>(new obj("unique_pointer"));
}

nocopy &return_reference_nocopy() {
static nocopy value("reference_nocopy");
Expand Down