473,378 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Template terminology question

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
4 1628
"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
"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

"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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

21
by: Sebastian Faust | last post by:
Hi, is a construction like the following possible: template<class view_model> class template_clase { protected: template_clase() {} virtual ~template_clase() {}
6
by: Dave | last post by:
Hello all, Consider this function template definition: template<typename T> void foo(T) {} If foo is never called, this template will never be instantiated. Now consider this explicit...
8
by: Thomas Heller | last post by:
I need to convert C preprocessor definitions into python code. The definitions are dumped out of gccxml (see http://www.gccxml.org) , running over the windows header files (for example). This...
16
by: christopher diggins | last post by:
It appears that the following is not considered a class: template<typename T> class C { }; ? So officially is this considered: a class, a template, a class template, or a template class? I...
5
by: Levent | last post by:
Hi, Why doesn't this work? (tried with gcc 3.3.3 and VC++ 7.1): #include <iostream> template<class T, unsigned N> struct Foo { void func(); }; template<class T, unsigned N>
3
by: Andy Fish | last post by:
Hi, Say I had a repeater-like situation but were I wanted to have every 3rd item look different instead of every alternating one. I could write my own custom control and in the ASPX file...
8
by: Imre | last post by:
Hi I'm looking for a way to make sure that whenever a new instance of a class template A is created, then an instance of class template B is also created, with the same template parameters. Of...
8
by: Rahul | last post by:
Hi, Is there a way to partially specialize only a member function of a template class (not the whole class). e.g. template <typename A, typename B> class Base { public:
5
by: (2b|!2b)==? | last post by:
I would like to know if I can specialize only a specific method for a class template. Is the (specialization) code below valid? template <typename T1, typename T2> class MyClass { public:
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.