Skip to content

Conversation

bansan85
Copy link
Contributor

@cubbimew
Copy link
Member

As you point out it's based on @RainerGrimm 's blog post about this Core Guidelines rule - is he ok with the example circling back here?
In any case "Concept" is a rather loaded word

@RainerGrimm
Copy link

RainerGrimm commented May 28, 2020 via email

@hsutter
Copy link
Contributor

hsutter commented May 28, 2020

Editors call: T.49 should have an example, but one that shows when and how to remove type erasure with something similar. This example belongs better in T.5 -- would you please move it there instead?

@bansan85
Copy link
Contributor Author

I moved the example to T.5.
I changed the type of concept_ to shared_ptr as the rule T.5 says.


class Object {
public:
template <typename T>
Copy link

Choose a reason for hiding this comment

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

I think this line has a more space between template <typename T> compared to other examples

class Object {
public:
template <typename T>
Object(T && obj)
Copy link

Choose a reason for hiding this comment

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

I think this line has a more space between T && compared to other examples

virtual int get_id() const = 0;
};

template <typename T>
Copy link

Choose a reason for hiding this comment

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

I think this line has a more space between template <typename T> compared to other examples


template <typename T>
struct Model final : Concept {
Model(T && obj) noexcept : object_(std::forward<T>(obj)) {}
Copy link

Choose a reason for hiding this comment

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

I think this line has a more space between T && compared to other examples

T object_;
};

std::shared_ptr<Concept> concept_;
Copy link

Choose a reason for hiding this comment

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

I think this line start with 2 spaces but other lines start with 4 spaces

@bansan85
Copy link
Contributor Author

@hyukmyeong Thanks, I have fixed everything.

@@ -16867,6 +16867,47 @@ Static helps dynamic: Use static polymorphism to implement dynamically polymorph
Dynamic helps static: Offer a generic, comfortable, statically bound interface, but internally dispatch dynamically, so you offer a uniform object layout.
Examples include type erasure as with `std::shared_ptr`'s deleter (but [don't overuse type erasure](#Rt-erasure)).

#include <memory>
Copy link
Member

Choose a reason for hiding this comment

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

could you start the example with "##### Example"?
also I still feel the naming of Concept and concept_ is distractingly close to the keyword concept

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cubbimew The example is already in an example (the line before "Dynamic helps static...").

I change the name of classes to be the same than the "Static helps dynamic" example.

Copy link
Member

Choose a reason for hiding this comment

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

great, thanks!

@cubbimew cubbimew merged commit 6d17d10 into isocpp:master Jul 29, 2020
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.

5 participants