Details
-
Type:
Code Smell Detection
-
Status: Active
-
Resolution: Unresolved
-
Labels:
-
Message:
-
Highlighting:
-
Default Severity:Minor
-
Impact:Low
-
Likelihood:Low
-
Default Quality Profiles:Sonar way, MISRA C++ 2008 recommended
-
Covered Languages:C, C++
-
Remediation Function:Constant/Issue
-
Constant Cost:30min
-
Analysis Scope:Main Sources, Test Sources
Description
Class templates can be explicitly or partially specialized. But according to the C++ standard, function templates cannot be partially specialized. Under certain conditions, the Microsoft® compiler will silently ignore the confusing application of partial specialization syntax to a function, but other compilers will raise an error for it and fail compilation.
Noncompliant Code Example
template<typename T> void fun(T p); template<typename T> void fun<T>(T p) { // Noncompliant // ... }
Compliant Solution
template<typename T>
void fun(T p);
template<typename T>
void fun(T p) {
// ...
}
Attachments
Issue Links
- is implemented by
-
CPP-1467 C++ Rule: Partial specialization syntax should not be used for function templates
-
- Closed
-
- relates to
-
SUPPORT-2490 Loading...