invalid explicit specification?

N

Nephi Immortal

When I try to use global function to call two class’ parameters, I got Compiler error message. I don’t see anything wrong in my code. What is going on?

main.cpp(1714): error C2770: invalid explicit template argument(s) for 'void Check(A<e,T>,A<e,T>::?$B@$QW4E@@(*(_BAAB@))$RT2@BAAC@$Q$R2BAAC@(*(_BAAD@)))'

main.cpp(1698) : see declaration of 'Check'

enum E
{
eA,
eB
};


template< E e, typename T >
struct A
{
template< E e2, typename T2, T2 size >
struct B
{
B()
{
}

~B()
{
}
};

A()
{
}

~A()
{
}

};

template< E e2, typename T2, T2 size >
void
Check(
A< e2, T2 > ref,
typename A< e2, T2 >::B< e2, T2, size > ref2
)
{
}


int main()
{
A< eA, int > a;
A< eA, int >::B< eA, int, 1 > b;

Check< eA, int, 1 >(
a,
b
);

return 0;
}
 
Ö

Öö Tiib

When I try to use global function to call two class’ parameters,
I got Compiler error message. I don’t see anything wrong in my
code. What is going on?

main.cpp(1714): error C2770: invalid explicit template argument(s)
for 'void Check(A<e,T>,A<e,T>::?$B@$QW4E@@(*(_BAAB@))
$RT2@BAAC@$Q$R2BAAC@(*(_BAAD@)))'

main.cpp(1698) : see declaration of 'Check'

That you should complain to Microsoft. Their error messages are indeed
close to useless. BTW ... you really have 1650 lines of trash in your
main.cpp?
enum E { eA, eB };

template< E e, typename T >
struct A
{
template< E e2, typename T2, T2 size >
struct B
{
B() { }
~B() { }
};

A() { }
~A() { }
};

Check(
A< e2, T2 > ref,
typename A< e2, T2 >::B< e2, T2, size > ref2
)
{
}

It should be:

template<E e2, typename T2, T2 sizex>
void Check( A<e2, T2> ref
, typename A<e2, T2>::template B<e2, T2, sizex> ref2 )
{ }

AFAIK 'template' is needed here ^^^^^^^^ to indicate usage of
nested template. Error comes at call site since compilers are not
required evaluate/diagnose template syntax much before actual
attempt to use it.
 
N

Nephi Immortal

That you should complain to Microsoft. Their error messages are indeed

close to useless. BTW ... you really have 1650 lines of trash in your

main.cpp?

Please do not say if I have 1650 lines of trash in my main.cpp. I have a lot of functions and/or classes above main() function. I select important lines so that I can post them to the newsgroups. You have no reason to readall 1650 lines!
It should be:



template<E e2, typename T2, T2 sizex>

void Check( A<e2, T2> ref

, typename A<e2, T2>::template B<e2, T2, sizex> ref2 )

{ }

I am not sure I understand your comment. I already posted “template< E e2, typename T2, T2 size > void”, but you deleted it before “Check(….)”. Why did you repost my copied line here?

Do GCC C++ Compiler and Intel C++ Compiler generate no error message with template implementation? It means that Microsoft does not do good job to write C++ Compiler themselves.

The alternative option is to move B class outside class A. I do not want client to access B class directly. I choose A struct and B struct so that Ican demonstrate template problem.
AFAIK 'template' is needed here ^^^^^^^^ to indicate usage of

nested template. Error comes at call site since compilers are not

required evaluate/diagnose template syntax much before actual

attempt to use it.

Do not make any sense since you deleted one line above.
 
S

Stuart

I am not sure I understand your comment. I already
posted “template< E e2, typename T2, T2 size > void”,
but you deleted it before “Check(….)”. Why did you
repost my copied line here?

Take a closer look. There is an additional keyword in the line that Öö
posted. He tried to draw your attention to this additional keyword by
adding the " ^^^^^^^^ " in the next line along with the word "here".
IMHO, this should be quite a strong hint.


See?

Regards,
Stuart

PS: You should use a different newsreader which does not add superflous
blank lines. That makes your posting difficult to read. Also there is a
netiquette that states that USENET postings should restrict the number
of characters to 80 per line. This makes posting readable with command
line clients and should not hurt too much since long lines are generally
bad to read.
 
Ö

Öö Tiib

Please do not say if I have 1650 lines of trash in my main.cpp.

The program looked like tiny test, I usually do not put such into
some file with important code. You are correct, it is none my business
to weight your practices.
Do GCC C++ Compiler and Intel C++ Compiler generate no error message
with template implementation?

I don't think that your original code compiles on other compilers.
I bashed Microsoft for the confusing "_BAAC!"@£%(*(_BAAD@))" vomits.
Do not make any sense since you deleted one line above.

I accidentally deleted it, sorry.
If that line helps you in any way then put it back.
What I wrote is anyway true, replacing yours 'Check' with mine works.
 
R

Rosario1903

When I try to use global function to call two class’ parameters, I got Compiler error message. I don’t see anything wrong in my code. What is going on?

main.cpp(1714): error C2770: invalid explicit template argument(s) for 'void Check(A<e,T>,A<e,T>::?$B@$QW4E@@(*(_BAAB@))$RT2@BAAC@$Q$R2BAAC@(*(_BAAD@)))'

main.cpp(1698) : see declaration of 'Check'

enum E
{
eA,
eB
};

are 'E' start names reserved?
than here not compile because don't find the definition for A.
a too much big subset of c++ is too much difficult
 

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,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top