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

template parameter #793

Closed
guwirth opened this issue Mar 2, 2016 · 3 comments · Fixed by #2116
Closed

template parameter #793

guwirth opened this issue Mar 2, 2016 · 3 comments · Fixed by #2116
Assignees
Labels
Milestone

Comments

@guwirth
Copy link
Collaborator

guwirth commented Mar 2, 2016

Leftover from #743, use case below is still not supported:

// @todo 
// #4, enabled via a template parameter
template<class T,
         typename std::enable_if<
             !std::is_trivially_destructible<T>{} &&
             (std::is_class<T>{} || std::is_union<T>{})
            >::type* = nullptr>
void destroy(T* t)
{
    std::cout << "destroying non-trivially destructible T\n";
    t->~T();
}
@guwirth guwirth added the bug label Mar 2, 2016
@guwirth guwirth added this to the 0.9.7 milestone Oct 17, 2016
@guwirth
Copy link
Collaborator Author

guwirth commented Oct 21, 2016

Hi @wichtounet you are our template expert here. Playing around with this I saw that they also changed the sample here: http://en.cppreference.com/w/cpp/types/enable_if. Which one is valid? Is the above one valid?

Asking this because the new sample is working also with our parser:

// #4, enabled via a template parameter
template<class T,
         typename std::enable_if<
             !std::is_trivially_destructible<T>{} &&
             (std::is_class<T>{} || std::is_union<T>{}),
            int>::type = 0>
void destroy(T* t)
{
    std::cout << "destroying non-trivially destructible T\n";
    t->~T();
}

@wichtounet
Copy link
Contributor

wichtounet commented Oct 23, 2016

Hi @guwirth,

Both are correct. Although, I would say the second (the new one your just posted) is a bit better because it uses int = 0 instead of void* = nullptr. In practice, for SFINAE, we can use any type that has constant expression values (integral types and pointer types).

The first one should still work with your parser, but if the second works it's already great :)

I guess that the problem with the first one is that you don't support pointers as non-type template parameter ?

@guwirth guwirth modified the milestones: subsequent release, 0.9.7 Dec 30, 2016
@guwirth
Copy link
Collaborator Author

guwirth commented Oct 14, 2017

@ametselaar we need your help. We have a hard grammar nut to crack.
Do you have some time to have a look to this issue?

@guwirth guwirth modified the milestones: 0.9.8, next Nov 14, 2017
@guwirth guwirth modified the milestones: 0.9.9, next Jan 1, 2018
@guwirth guwirth removed this from the next milestone Jan 16, 2018
@guwirth guwirth added this to the 1.2.1 milestone Nov 14, 2018
@guwirth guwirth modified the milestones: 1.2.1, 1.2.2 Dec 23, 2018
@guwirth guwirth removed this from the 1.2.2 milestone Feb 9, 2019
@guwirth guwirth added this to the 2.0.0 milestone Apr 14, 2021
guwirth added a commit to guwirth/sonar-cxx that referenced this issue Apr 22, 2021
@guwirth guwirth self-assigned this Apr 22, 2021
guwirth added a commit to guwirth/sonar-cxx that referenced this issue May 3, 2021
- C++/CLI ...::typeid
- close SonarOpenCommunity#793
- fix parametersAndQualifiers / trailingReturnType
- declaratorId
- assignmentExpression
- parametersAndQualifiers
- parse & print grammar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging a pull request may close this issue.

2 participants