Victor Bazarov wrote:
::
su**************@yahoo.com wrote:
::: 14.7.1.(9) from the C++ standard: "An implementation shall not
::: implicitly instantiate a function template, a member template, a
::: nonvirtual member function, a member class or a static data
::: member of a class template that does not require instantiation"
:::
::: Here, what does 'member template' mean ?
::
:: template<class Tclass A {}; // class template
:: template<class Tvoid foo(T); // function template
:: template<class Tclass B {
:: void foo(); // non-virtual function
:: static int i; // data member
:: template<class Tint blah(); // member template
:: template<class Tclass S {}; // member template
:: };
::
::: In the above statement, kindly explain the line(if possible please
::: give an example)
::: "a member class or a static data member of a class template that
::: does not require instantiation"
::
:: If the class template that doesn't require instantiation (never
:: used in the program in such way that would cause instantiation), a
:: member template of that class [template] and other elements that
:: are really templates, shouldn't require instantiation either. To
:: keep the code from being bloated from the unnecessary
:: instantiations of the class members the Standard explicitly
:: prohibits those. At least that's how I read it.
::
It also saves you from the problem that some members, like perhaps
foo(), cannot be instantiated for all T's. This is not an error,
unless someone actually calls foo() for that T.
Bo Persson