Skip to content
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

use make_shared #29

Closed
wants to merge 1 commit into from
Closed

Conversation

pragmaticQt
Copy link

Pull Request Template

Description

C++ Core Guidelines
C.151: Use make_shared() to construct objects owned by shared_ptrs.

Fixes # (issue)

How Has This Been Tested?

GCC9.2.0.

  • Test build and run.

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

@phillipjohnston
Copy link
Member

Happy to make this change, but the build currently fails due to template parameter mismatch:

c++ -Iexamples/cpp/813c7e2@@shared_ptr@exe -Iexamples/cpp -I../examples/cpp -Xclang -fcolor-diagnostics -pipe -Wall -Winvalid-pch -Wnon-virtual-dtor -std=c++17 -g -Wno-unknown-pragmas -fno-rtti -fno-exceptions -fno-unwind-tables -MD -MQ 'examples/cpp/813c7e2@@shared_ptr@exe/shared_ptr.cpp.o' -MF 'examples/cpp/813c7e2@@shared_ptr@exe/shared_ptr.cpp.o.d' -o 'examples/cpp/813c7e2@@shared_ptr@exe/shared_ptr.cpp.o' -c ../examples/cpp/shared_ptr.cpp
../examples/cpp/shared_ptr.cpp:27:21: error: unknown type name 'Arg'
                        EnableMakeShared(Arg&&... arg) : SharedThing(std::forward<Arg>(arg)...) {}
                                         ^
../examples/cpp/shared_ptr.cpp:27:26: error: type 'int &&' of function parameter pack does not contain any unexpanded parameter packs
                        EnableMakeShared(Arg&&... arg) : SharedThing(std::forward<Arg>(arg)...) {}
                                         ~~~~~^~~~~~~
../examples/cpp/shared_ptr.cpp:27:62: error: use of undeclared identifier 'Arg'; did you mean 'arg'?
                        EnableMakeShared(Arg&&... arg) : SharedThing(std::forward<Arg>(arg)...) {}
                                                                                  ^~~
                                                                                  arg
../examples/cpp/shared_ptr.cpp:27:30: note: 'arg' declared here
                        EnableMakeShared(Arg&&... arg) : SharedThing(std::forward<Arg>(arg)...) {}
                                                  ^
../examples/cpp/shared_ptr.cpp:29:58: error: use of undeclared identifier 'Arg'
                return std::make_shared<EnableMakeShared>(std::forward<Arg>(arg)...);

Copy link
Member

@phillipjohnston phillipjohnston left a comment

Choose a reason for hiding this comment

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

Please add a comment above the struct explaining what its purpose is to the uninitiated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants