Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rul1 14-7-1 and explicit class instantiation
#1
Does this rule should detect functions in template classes, that have no instances, but the class is explicitly instantiated?
In this case member functions are instantiated accordingly to the C++ standard:

Quote:8 An explicit instantiation that names a class template specialization is also an explicit instantiation of the
same kind (declaration or definition) of each of its members (not including members inherited from base
classes and members that are templates) that has not been previously explicitly specialized in the translation
unit containing the explicit instantiation, except as described below. [ Note: In addition, it will typically be
an explicit instantiation of certain implementation-dependent data about the class. —end note ]
9 An explicit instantiation definition that names a class template specialization explicitly instantiates the class
template specialization and is an explicit instantiation definition of only those members that have been
defined at the point of instantiation.
but these functions are never used.

Example:

Code:
template <typename T>
class Temp {
    public:
    void f1(){}  // Compliant?
    void f2(){}  // Compliant?
};

template class Temp<int>;
Reply


Messages In This Thread
Rul1 14-7-1 and explicit class instantiation - by mstaron - 30-08-2023, 06:58 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)