473,842 Members | 1,866 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

implicit type template warning

Hi

Can somebody explain to me why I get this warning message and how I
can solve this warning message.

Thanks a lot

Johan

In member function `void
Callback1<Par>: :search()':
b.cpp:44: warning: `typename std::vector<Cal lback<Par>,
std::allocator< Callback<Par> > >::iterator' is implicitly a
typename
b.cpp:44: warning: implicit typename is deprecated, please see the
documentation for details
template <class Par>
class Callback
{
public :
Callback(const Par& par) : par(par)
{
}
~Callback()
{
}

void show()
{
cout << par << endl;
}

private :
Par par;
};
template <class Par>
class Callback1 : public Callback<Par>
{
public :
typedef Callback< Par > CallbackPar;

Callback1(const Par& par) : Callback<Par>(p ar)
{
v.push_back(par );
}
~Callback1()
{
}

void search()
{
vector< Callback< Par > >::iterator i;
}

private :
vector< Callback< Par > > v;
};

b.cpp: In member function `void Callback1<Par>: :search()':
b.cpp:44: warning: `typename std::vector<Cal lback<Par>,
std::allocator< Callback<Par> > >::iterator' is implicitly a
typename
b.cpp:44: warning: implicit typename is deprecated, please see the
documentation for details
Jul 22 '05 #1
11 1882

Johan wrote:
Hi

Can somebody explain to me why I get this warning message and how I
can solve this warning message. In member function `void
Callback1<Par>: :search()':
b.cpp:44: warning: `typename std::vector<Cal lback<Par>,
std::allocator< Callback<Par> > >::iterator' is implicitly a
typename
b.cpp:44: warning: implicit typename is deprecated, please see the
documentation for details .... template <class Par>
class Callback1 : public Callback<Par> {
void search() {
vector< Callback< Par > >::iterator i;


Sure. What kind of name is iterator, a template, a variable, or a type
(enum/typedef/nested class)? The compiler will know this only when it
knows what Par is, but when the template is compiled this isn't yet
known. Par will be provided later during instantiation.

The warning tells you that the compiler guessed, and it guessed
correctly. iterator is a typename. To prevent the warning, be
explicit and put the typename in yourself.
BTW, the warning said "RTFM", didn't it include this?
Regards,
Michiel Salters

Jul 22 '05 #2

"msalters" <Mi************ *@logicacmg.com > wrote in message news:11******** *************@c 13g2000cwb.goog legroups.com...

Johan wrote:
Hi

Can somebody explain to me why I get this warning message and how I
can solve this warning message.

In member function `void
Callback1<Par>: :search()':
b.cpp:44: warning: `typename std::vector<Cal lback<Par>,
std::allocator< Callback<Par> > >::iterator' is implicitly a
typename
b.cpp:44: warning: implicit typename is deprecated, please see the
documentation for details

...
template <class Par>
class Callback1 : public Callback<Par> {
void search() {
vector< Callback< Par > >::iterator i;


Sure. What kind of name is iterator, a template, a variable, or a type
(enum/typedef/nested class)? The compiler will know this only when it
knows what Par is, but when the template is compiled this isn't yet
known. Par will be provided later during instantiation.

The warning tells you that the compiler guessed, and it guessed
correctly. iterator is a typename. To prevent the warning, be
explicit and put the typename in yourself.


So,
typename vector< Callback< Par > >::iterator i;

Can something else be instead of 'typename'?

[snip]
--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn


Jul 22 '05 #3
Alex Vinokur wrote:
So,
typename vector< Callback< Par > >::iterator i;

Can something else be instead of 'typename'?


If you don't include 'typename' the compiler has to assume that it
is a value. For standard classes this may seem to be unreasable
because you have a hard time to get something else than a type
without violating some other rule but the same rule applies here
as to user defined types. For these it is pretty easy to have a
value or a type in a context and the compiler could, without the
typename, only detect the correct meaning at instantiation type.
--
<mailto:di***** ******@yahoo.co m> <http://www.dietmar-kuehl.de/>
<http://www.contendix.c om> - Software Development & Consulting

Jul 22 '05 #4

"Dietmar Kuehl" <di***********@ yahoo.com> wrote in message news:11******** *************@f 14g2000cwb.goog legroups.com...
Alex Vinokur wrote:
So,
typename vector< Callback< Par > >::iterator i;

Can something else be instead of 'typename'?


If you don't include 'typename' the compiler has to assume that it
is a value.
For standard classes this may seem to be unreasable
because you have a hard time to get something else than a type
without violating some other rule but the same rule applies here
as to user defined types. For these it is pretty easy to have a
value or a type in a context and the compiler could, without the
typename, only detect the correct meaning at instantiation type.

[snip]

------ foo.cpp ------
#include <vector>
using namespace std;

template <typename T>
struct Foo
{
vector<int>::it erator iter1;
typename vector<T>::iter ator iter2;
};

int main()
{
Foo<double> f;
return 0;
}
---------------------

Is iter1 a value?
Is iter2 a typename?
--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn


Jul 22 '05 #5
Alex Vinokur wrote:
template <typename T>
struct Foo
{
vector<int>::it erator iter1;
typename vector<T>::iter ator iter2;
};

int main()
{
Foo<double> f;
return 0;
}
---------------------

Is iter1 a value?
Is iter2 a typename?


You mean, I failed to mention that 'typename' is only necessary
if it applies to a dependent name? (and currently prohbited if
not necessary; it is discussed to change the latter rule) Fair
enough: both 'iter1' and 'iter2' are type names because 'iter1'
does not depend on a template parameter and it is guaranteed to
the compiler that 'iter2' is indeed a type name.
--
<mailto:di***** ******@yahoo.co m> <http://www.dietmar-kuehl.de/>
<http://www.contendix.c om> - Software Development & Consulting

Jul 22 '05 #6
Dietmar Kuehl wrote:
Alex Vinokur wrote:
template <typename T>
struct Foo
{
vector<int>::it erator iter1;
typename vector<T>::iter ator iter2;
};

int main()
{
Foo<double> f;
return 0;
}
---------------------

Is iter1 a value?
Is iter2 a typename?

You mean, I failed to mention that 'typename' is only necessary
if it applies to a dependent name? (and currently prohbited if
not necessary; it is discussed to change the latter rule) Fair
enough: both 'iter1' and 'iter2' are type names because 'iter1'
does not depend on a template parameter and it is guaranteed to
the compiler that 'iter2' is indeed a type name.


Uh... I somehow thought that 'iter1' and 'iter2' are member names.

V
Jul 22 '05 #7

"Victor Bazarov" <v.********@com Acast.net> wrote in message news:Sy******** ***********@new sread1.mlpsca01 .us.to.verio.ne t...
Dietmar Kuehl wrote:
Alex Vinokur wrote:
template <typename T>
struct Foo
{
vector<int>::it erator iter1;
typename vector<T>::iter ator iter2;
};

int main()
{
Foo<double> f;
return 0;
}
---------------------

Is iter1 a value?
Is iter2 a typename?

You mean, I failed to mention that 'typename' is only necessary
if it applies to a dependent name? (and currently prohbited if
not necessary; it is discussed to change the latter rule) Fair
enough: both 'iter1' and 'iter2' are type names because 'iter1'
does not depend on a template parameter and it is guaranteed to
the compiler that 'iter2' is indeed a type name.


Uh... I somehow thought that 'iter1' and 'iter2' are member names.

V


It seems that _iterators_ in 'vector<int>::i terator' and 'typename vector<T>::iter ator' are type names (?).

--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn



Jul 22 '05 #8
Alex Vinokur wrote:
"Victor Bazarov" <v.********@com Acast.net> wrote in message
news:Sy******** ***********@new sread1.mlpsca01 .us.to.verio.ne t...
Dietmar Kuehl wrote:
Alex Vinokur wrote:
template <typename T> struct Foo { vector<int>::it erator iter1;
typename vector<T>::iter ator iter2; };

int main() { Foo<double> f; return 0; } ---------------------

Is iter1 a value? Is iter2 a typename?
You mean, I failed to mention that 'typename' is only necessary if
it applies to a dependent name? (and currently prohbited if not
necessary; it is discussed to change the latter rule) Fair enough:
both 'iter1' and 'iter2' are type names because 'iter1' does not
depend on a template parameter and it is guaranteed to the compiler
that 'iter2' is indeed a type name.


Uh... I somehow thought that 'iter1' and 'iter2' are member names.

V

It seems that _iterators_ in 'vector<int>::i terator' and 'typename
vector<T>::iter ator' are type names (?).


Yes, they are. And it doesn't just seem so, it _is_ so. I was simply
surprised by the use of <<'iter1'>> and <<'iter2'>> in Dietmar's reply.

V
Jul 22 '05 #9

"Victor Bazarov" <v.********@com Acast.net> wrote in message news:4W******** ***********@new sread1.mlpsca01 .us.to.verio.ne t...
Alex Vinokur wrote:
"Victor Bazarov" <v.********@com Acast.net> wrote in message
news:Sy******** ***********@new sread1.mlpsca01 .us.to.verio.ne t...
Dietmar Kuehl wrote:

Alex Vinokur wrote:
> template <typename T> struct Foo { vector<int>::it erator iter1;
> typename vector<T>::iter ator iter2; };
>
> int main() { Foo<double> f; return 0; } ---------------------
>
> Is iter1 a value? Is iter2 a typename?
You mean, I failed to mention that 'typename' is only necessary if
it applies to a dependent name? (and currently prohbited if not
necessary; it is discussed to change the latter rule) Fair enough:
both 'iter1' and 'iter2' are type names because 'iter1' does not
depend on a template parameter and it is guaranteed to the compiler
that 'iter2' is indeed a type name.

Uh... I somehow thought that 'iter1' and 'iter2' are member names.

V

It seems that _iterators_ in 'vector<int>::i terator' and 'typename
vector<T>::iter ator' are type names (?).


Yes, they are. And it doesn't just seem so, it _is_ so. I was simply
surprised by the use of <<'iter1'>> and <<'iter2'>> in Dietmar's reply.

V

Here are a sample connected to the issue.

------ file.cpp ------
struct Foo
{
struct Bar {};
static void foo (int) {}
static int data;
};
int Foo::data(0);

template <typename T>
struct Blah
{
Foo::Bar b1; // 'Bar' is explicit type name, b1 is value
Foo::Bar (b2); // 'Bar' is explicit type name, b2 is value

// T::Bar b3; // 'Bar' is implicit type name
// T::Bar (b4); // 'Bar' is implicit type name

typename T::Bar b3; // Now 'Bar' is explicit type name, b3 is value
typename T::Bar (b4); // Now 'Bar' is explicit type name, b4 is value

void blah1 () { int x(0); T::foo(x); } // 'foo' is explicit function name
void blah2 () { T::data; } // 'data' is explicit value name

// ----------------------
void blah3 (Foo::Bar, typename T::Bar, void (*)(int), int) {}
// 'Bar' in Foo::Bar is explicit type name
// 'Bar' in T::Bar is now explicit type name
// ----------------------
};

int main()
{
Foo::Bar bar;

Blah<Foo> blah;

// ---------
blah.blah1();

blah.blah2();
// ---------

// ----------------------------------------
blah.blah3 (bar, bar, Foo::foo, Foo::data);
// 'foo' is explicit function name
// 'data' is explicit value name
// ----------------------------------------

return 0;
}

----------------------

See also http://www.glenmccl.com/ansi_035.htm .
--
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn


Jul 22 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3871
by: Steve Hill | last post by:
Hi, When compiling under g++ (version 3.2) the following code fragement gives me a warning: steve@khan:~/tmp> /opt/bin/g++ -o state_test state_test.cpp state_test.cpp:42: warning: `typename State<T>::State_change_counter' is implicitly a typename state_test.cpp:42: warning: implicit typename is deprecated, please see the documentation for details Any ideas why, and how to avoid it?
1
1389
by: Marcin Kalicinski | last post by:
Hi, The following code template<class Type> class Base::List: public std::list<Type> { public: explicit List(size_type count): std::list<Type>(count) { } // this is line 14 /*...*/
3
1894
by: Šimon Tóth | last post by:
Can anybody tell me how to turn of this warning? -Wno-deprecated doesn't work. I don't want to edit the source file, because it works fine and it's a bit hardcore stuff for me :) warning: implicit typename is deprecated, please see the documentation for details
1
1773
by: lutorm | last post by:
Hi all, I'm working on migrating my code from KCC to gcc, and I'm having some issues with "implicit typename" warnings from gcc. Essentially, what happens is described by this example: template <typename cell_data_type> class cell {}; template <typename a> class c1 { public: typedef cell<a> T_cell;
1
2154
by: pmatos | last post by:
Hi all, I'm starting to use templates and I just got a weird error which I was able to simplify into this code: #include <vector> using std::vector; template<class T> class foo {
3
2964
by: Generic Usenet Account | last post by:
This is a two-part question. (1) I have implemented a "Datastructure Registry" template class. I am getting no compiler warnings with older compilers, but newer compilers are generating the following error messages: warning: implicit typename is deprecated, please see the documentation for details Can someone kindly suggest how to get rid of these warnings? The source code follows.
15
2306
by: buda | last post by:
Let me see if I got this :) 1. I know the rules for type conversions in arithmetic expressions 2. I know that an implicit type conversion is done at assignment, so float x = 1.23; int t = (int) x; is equivalent to int t = x; (could the latter produce a warning on some complier?) 3. I know that implicit conversions take place with function arguments, but am a bit shaky here. I suppose that passing a char to a function accepting
8
1783
by: xuatla | last post by:
Hi, When I compile the following test code I got a warning about implicit typename. This happens in the member functions. Do you know the detail reason and solution? Thanks. - X ----------
18
2395
by: Tony | last post by:
class Interface { public: virtual void DoItNow()=0; }; class A: public Interface { public: void DoItNow(); // satisfies interface explicitly
0
10934
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10609
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10668
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7025
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5694
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4085
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3140
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.