Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > invalid explicit specification?

Reply
Thread Tools

invalid explicit specification?

 
 
Nephi Immortal
Guest
Posts: n/a
 
      02-07-2013
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@BA AC@$Q$R2BAAC@(*(_BAAD@)))'

main.cpp(169 : 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;
}
 
Reply With Quote
 
 
 
 
Öö Tiib
Guest
Posts: n/a
 
      02-07-2013
On Thursday, 7 February 2013 05:18:54 UTC+2, Nephi Immortal wrote:
> 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(169 : 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.

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


 
Reply With Quote
 
 
 
 
Nephi Immortal
Guest
Posts: n/a
 
      02-07-2013
On Thursday, February 7, 2013 6:17:52 AM UTC-6, Öö Tiib wrote:
> On Thursday, 7 February 2013 05:18:54 UTC+2, Nephi Immortal wrote:
>
> > 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(169 : 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?


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!

>
>
>
> > 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 )
>
> { }


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.

>
>
>
> > int main()

>
> > {

>
> > A<eA, int> a;

>
> > A<eA, int>::B<eA, int, 1> b;

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

>
> > return 0;

>
> > }


 
Reply With Quote
 
Stuart
Guest
Posts: n/a
 
      02-08-2013
On Thursday, 7 February 2013, Nephi Immortal wrote:
>>> 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(169 : 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() { }
>>> };
>>>
>>> Check(
>>> A< e2, T2 > ref,
>>> typename A< e2, T2 >::B< e2, T2, size > ref2
>>> )
>>> {
>>> }


On February 7, 2013, Öö Tiib wrote:
>> 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 )
>> { }


On 02/07/13, Nephi Immortal wrote:
> 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.

On February 7, 2013, Öö Tiib wrote:
>> AFAIK 'template' is needed here ^^^^^^^^ to indicate usage of


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.

 
Reply With Quote
 
Öö Tiib
Guest
Posts: n/a
 
      02-08-2013
On Thursday, 7 February 2013 22:48:43 UTC+2, Nephi Immortal wrote:
> 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.
 
Reply With Quote
 
Rosario1903
Guest
Posts: n/a
 
      02-10-2013
On Wed, 6 Feb 2013 19:18:54 -0800 (PST), Nephi Immortal
<(E-Mail Removed)> wrote:

>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@BA AC@$Q$R2BAAC@(*(_BAAD@)))'
>
>main.cpp(169 : 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Explicit instantiation of STL vector demands explicit instantiation of all the templates it using internally. krunalbauskar@gmail.com C++ 1 12-25-2006 03:51 PM
Invalid URI: There is an invalid sequence in the string. Error!! Patrick.O.Ige ASP .Net 1 07-02-2006 11:21 AM
What's the difference betwwen explicit instantiaion and explicit specialization? Andy C++ 5 01-30-2005 11:46 PM
invalid@invalid.org Hank Sniadoch Computer Information 1 08-20-2004 11:24 AM
Is explicit template qualification required for explicit delete? J.T. Conklin C++ 1 08-11-2004 02:06 AM



Advertisments