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

Allowing partial specialization of the convert struct #922

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

BenjaminNavarro
Copy link

This is done by adding a second, defaulted, template parameter that can
be used in conjunction of std::enable_if

An example of usage is added to the tutorial

The code and example has been taken from #310

@BenjaminNavarro
Copy link
Author

How should I approach the testing of this? It's easy to check that it works for the correct subset of types but not that it doesn't for the others since it would create a compilation error

@BenjaminNavarro
Copy link
Author

I added a small test to make sure that the feature works and to potentially avoid future regressions.

Let me know if you require more testing

@BenjaminNavarro
Copy link
Author

@jbeder Could you review this PR when you have time?

class B : public A {
public:
// override virtual load/emit methods
virtual void load(const YAML::Node &node) override {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Even though it's a test case, I think the constructors are needed, like #310. It is also convenient for later usage.

Copy link
Author

Choose a reason for hiding this comment

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

Added

Copy link
Collaborator

Choose a reason for hiding this comment

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

How about updating the Tutorial.md at the same time. And use this in testcase.

  A a(1);
  B b(1, 2);

Copy link
Author

Choose a reason for hiding this comment

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

I updated the test cases to use the constructors and added them in the tutorial.
However the tutorial doesn't make use of them

test/integration/convert_partial_specialization_test.cpp Outdated Show resolved Hide resolved
@pettni
Copy link

pettni commented Oct 20, 2020

I am also interested in getting this merged, was actually about to submit the same merge request myself. This change would facilitate using yaml-cpp in conjunction with reflection tools such as boost::hana and boost::fusion, and I don't see any drawbacks of adding the second default template argument.

Stackoverflow discussion that discusses the issue of not being able to use SFINAE without a second template paramter.

@yuriy1337
Copy link

Is there a plan for getting this merged. I am also interested in this functionality.

This is done by adding a second, defaulted, template parameter that can
be used in conjunction of std::enable_if

An example of usage is added to the tutorial
@BenjaminNavarro
Copy link
Author

Is there any hope to see this merged eventually? It would be a life saver

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.

4 participants