Questions tagged [implicit-instantiation]

In the C++ language, implicit instantiation is the process of creating a class or function from a class template or function template when this particular type has not been explicitly instantiated.

5 questions
12
votes
1 answer

Is use in an unused default member initializer still an odr-use?

Is use in a default member initializer still an odr-use, even if the default member initializer is not used by any constructor? For example, is this program ill-formed because g is odr-used and therefore its definition implicitly…
11
votes
1 answer

function template with unused template parameter

template struct a { using type = int; typename T::type i; }; template> void f1(T) {} template::type> void f2(T) {} int main() { f1(1); // ok f2(1);…
olist
  • 877
  • 5
  • 13
10
votes
1 answer

Is a specialization implicitly instantiated if it has already been implicitly instantiated?

The question in the title is clear enough. To be more specific, consider the following example: #include template struct is_complete_helper { template static auto test(U*) ->…
5
votes
1 answer

Does "used as non-type template parameter" make a function template implicitly instantiated?

I want to write a class template M that accepts incomplete type C as template parameter. But I also want C has some traits when it is eventually defined. Is this code guaranteed to compile if defined(FLAG), and to fail the compiling if…
2
votes
1 answer

Does `using` in a template class force instantiation?

This question is on how to use global variable initialization to achieve some side effect before main() is run (e.g., factory class registration before main()). This can be tricky when template is involved. Consider the following piece of…