By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,507 Members | 1,758 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,507 IT Pros & Developers. It's quick & easy.

Template terminology question

P: n/a
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
Jul 22 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"Dave" <be***********@yahoo.com> wrote...
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<int>(42);
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
Jul 22 '05 #2

P: n/a
"Dave" <be***********@yahoo.com> wrote in message
news:10*************@news.supernews.com...
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."

--
David Hilsee
Jul 22 '05 #3

P: n/a

"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:2bVRc.276465$Oq2.275064@attbi_s52...
"Dave" <be***********@yahoo.com> wrote...
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<int>(42);
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


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?
Jul 22 '05 #4

P: n/a
"Dave" <be***********@yahoo.com> wrote...
"Victor Bazarov" <v.********@comAcast.net> wrote in message
news:2bVRc.276465$Oq2.275064@attbi_s52...
"Dave" <be***********@yahoo.com> wrote...
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<int>(42);
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


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[s] is[are] deduced. In the former case the argument (int) is
deduced
from the function argument, in the latter it's explicitly specified.

Victor
Jul 22 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.