Template terminology question

D

Dave

Hello all,

Consider this template:

template <typename T>
void foo(T bar) {...}

Here are three ways to instantiate this:

1.
This line of code triggers an "implicit instantiation via argument
deduction":
bar(10);

2.
This line of code triggers an "explicit instantiation":
template foo(int bar);

3.
Then there's this way of instnatiating the template:
bar<int>(42);

My questions are:

Has terminology been coined to refer to case 3?

The terminology "implicit instantiation via argument deduction" in case 1
was made up by me. Is there an accepted, in-common-use term for this type
of instantiation?

Thanks,
Dave
 
V

Victor Bazarov

Dave said:
Consider this template:

template <typename T>
void foo(T bar) {...}

Here are three ways to instantiate this:

1.
This line of code triggers an "implicit instantiation via argument
deduction":
bar(10);

You mean

foo(10);

And, "causes" is used rather than "triggers".
2.
This line of code triggers an "explicit instantiation":
template foo(int bar);

"Triggers"? The code simply explicitly instantiates the template.
3.
Then there's this way of instnatiating the template:
bar<int>(42);

Again, you mean

foo said:
My questions are:

Has terminology been coined to refer to case 3?

It's a function call. The template arguments are explicitly specified.
The terminology "implicit instantiation via argument deduction" in case 1
was made up by me. Is there an accepted, in-common-use term for this type
of instantiation?

Sounds OK.

Victor
 
D

David Hilsee

Dave said:
Hello all,

Consider this template:

template <typename T>
void foo(T bar) {...}

Here are three ways to instantiate this:

1.
This line of code triggers an "implicit instantiation via argument
deduction":
bar(10);

2.
This line of code triggers an "explicit instantiation":
template foo(int bar);

3.
Then there's this way of instnatiating the template:
bar<int>(42);

My questions are:

Has terminology been coined to refer to case 3?

It's implicit instantion, but there is no argument deduction because the
arguments were explicitly specified.
The terminology "implicit instantiation via argument deduction" in case 1
was made up by me. Is there an accepted, in-common-use term for this type
of instantiation?

You just combined two accepted terms together using "via," so I think most
people would be OK with how you put it. It sounds like saying "calling a
function via dynamic binding."
 
D

Dave

Victor Bazarov said:
You mean

foo(10);

And, "causes" is used rather than "triggers".


"Triggers"? The code simply explicitly instantiates the template.


Again, you mean



It's a function call. The template arguments are explicitly specified.


Sounds OK.

Victor

Yep, I got my foos and bars mixed up (it's been a long day!), and "causes"
Vs. "triggers" was not the terminology I was seeking clarification on. I'm
just trying to find out if there is standard, accepted terminology for the
three instantiation mechanisms I listed. "Explicit instantiation" in case 2
is the only one I'm sure of. Allow me to try again:

template <typename T>
void foo(T bar) {...}

foo(10);
foo<int>(42);

Both of these lines of code cause instantiation, but each does it in a
different way. Is there standard, accepted terminology for these two
different instantiation mechanisms?
 
V

Victor Bazarov

Dave said:
case

Yep, I got my foos and bars mixed up (it's been a long day!), and "causes"
Vs. "triggers" was not the terminology I was seeking clarification on. I'm
just trying to find out if there is standard, accepted terminology for the
three instantiation mechanisms I listed. "Explicit instantiation" in case 2
is the only one I'm sure of. Allow me to try again:

template <typename T>
void foo(T bar) {...}

foo(10);
foo<int>(42);

Both of these lines of code cause instantiation, but each does it in a
different way. Is there standard, accepted terminology for these two
different instantiation mechanisms?

No. Both instantiations are implicit. The difference in the way the
template
argument is[are] deduced. In the former case the argument (int) is
deduced
from the function argument, in the latter it's explicitly specified.

Victor
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top